kityminder.editor.js 180 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668
  1. /*!
  2. * ====================================================
  3. * kityminder-editor - v1.0.67 - 2022-05-25
  4. * https://github.com/fex-team/kityminder-editor
  5. * GitHub: https://github.com/fex-team/kityminder-editor
  6. * Copyright (c) 2022 ; Licensed
  7. * ====================================================
  8. */
  9. (function () {
  10. var _p = {
  11. r: function(index) {
  12. if (_p[index].inited) {
  13. return _p[index].value;
  14. }
  15. if (typeof _p[index].value === "function") {
  16. var module = {
  17. exports: {}
  18. }, returnValue = _p[index].value(null, module.exports, module);
  19. _p[index].inited = true;
  20. _p[index].value = returnValue;
  21. if (returnValue !== undefined) {
  22. return returnValue;
  23. } else {
  24. for (var key in module.exports) {
  25. if (module.exports.hasOwnProperty(key)) {
  26. _p[index].inited = true;
  27. _p[index].value = module.exports;
  28. return module.exports;
  29. }
  30. }
  31. }
  32. } else {
  33. _p[index].inited = true;
  34. return _p[index].value;
  35. }
  36. }
  37. };
  38. //src/editor.js
  39. _p[0] = {
  40. value: function(require, exports, module) {
  41. /**
  42. * 运行时
  43. */
  44. var runtimes = [];
  45. function assemble(runtime) {
  46. runtimes.push(runtime);
  47. }
  48. function KMEditor(selector) {
  49. this.selector = selector;
  50. for (var i = 0; i < runtimes.length; i++) {
  51. if (typeof runtimes[i] == "function") {
  52. runtimes[i].call(this, this);
  53. }
  54. }
  55. }
  56. KMEditor.assemble = assemble;
  57. assemble(_p.r(7));
  58. assemble(_p.r(9));
  59. assemble(_p.r(14));
  60. assemble(_p.r(18));
  61. assemble(_p.r(11));
  62. assemble(_p.r(12));
  63. assemble(_p.r(5));
  64. assemble(_p.r(6));
  65. assemble(_p.r(8));
  66. assemble(_p.r(15));
  67. assemble(_p.r(10));
  68. assemble(_p.r(13));
  69. assemble(_p.r(16));
  70. assemble(_p.r(17));
  71. return module.exports = KMEditor;
  72. }
  73. };
  74. //src/expose-editor.js
  75. /**
  76. * @fileOverview
  77. *
  78. * 打包暴露
  79. *
  80. * @author: techird
  81. * @copyright: Baidu FEX, 2014
  82. */
  83. _p[1] = {
  84. value: function(require, exports, module) {
  85. return module.exports = kityminder.Editor = _p.r(0);
  86. }
  87. };
  88. //src/hotbox.js
  89. _p[2] = {
  90. value: function(require, exports, module) {
  91. return module.exports = window.HotBox;
  92. }
  93. };
  94. //src/lang.js
  95. _p[3] = {
  96. value: function(require, exports, module) {}
  97. };
  98. //src/minder.js
  99. _p[4] = {
  100. value: function(require, exports, module) {
  101. return module.exports = window.kityminder.Minder;
  102. }
  103. };
  104. //src/runtime/clipboard-mimetype.js
  105. /**
  106. * @Desc: 新增一个用于处理系统ctrl+c ctrl+v等方式导入导出节点的MIMETYPE处理,如系统不支持clipboardEvent或者是FF则不初始化改class
  107. * @Editor: Naixor
  108. * @Date: 2015.9.21
  109. */
  110. _p[5] = {
  111. value: function(require, exports, module) {
  112. function MimeType() {
  113. /**
  114. * 私有变量
  115. */
  116. var SPLITOR = "\ufeff";
  117. var MIMETYPE = {
  118. "application/km": "￿"
  119. };
  120. var SIGN = {
  121. "\ufeff": "SPLITOR",
  122. "￿": "application/km"
  123. };
  124. /**
  125. * 用于将一段纯文本封装成符合其数据格式的文本
  126. * @method process private
  127. * @param {MIMETYPE} mimetype 数据格式
  128. * @param {String} text 原始文本
  129. * @return {String} 符合该数据格式下的文本
  130. * @example
  131. * var str = "123";
  132. * str = process('application/km', str); // 返回的内容再经过MimeType判断会读取出其数据格式为application/km
  133. * process('text/plain', str); // 若接受到一个非纯文本信息,则会将其转换为新的数据格式
  134. */
  135. function process(mimetype, text) {
  136. if (!this.isPureText(text)) {
  137. var _mimetype = this.whichMimeType(text);
  138. if (!_mimetype) {
  139. throw new Error("unknow mimetype!");
  140. }
  141. text = this.getPureText(text);
  142. }
  143. if (mimetype === false) {
  144. return text;
  145. }
  146. return mimetype + SPLITOR + text;
  147. }
  148. /**
  149. * 注册数据类型的标识
  150. * @method registMimeTypeProtocol public
  151. * @param {String} type 数据类型
  152. * @param {String} sign 标识
  153. */
  154. this.registMimeTypeProtocol = function(type, sign) {
  155. if (sign && SIGN[sign]) {
  156. throw new Error("sing has registed!");
  157. }
  158. if (type && !!MIMETYPE[type]) {
  159. throw new Error("mimetype has registed!");
  160. }
  161. SIGN[sign] = type;
  162. MIMETYPE[type] = sign;
  163. };
  164. /**
  165. * 获取已注册数据类型的协议
  166. * @method getMimeTypeProtocol public
  167. * @param {String} type 数据类型
  168. * @param {String} text|undefiend 文本内容或不传入
  169. * @return {String|Function}
  170. * @example
  171. * text若不传入则直接返回对应数据格式的处理(process)方法
  172. * 若传入文本则直接调用对应的process方法进行处理,此时返回处理后的内容
  173. * var m = new MimeType();
  174. * var kmprocess = m.getMimeTypeProtocol('application/km');
  175. * kmprocess("123") === m.getMimeTypeProtocol('application/km', "123");
  176. *
  177. */
  178. this.getMimeTypeProtocol = function(type, text) {
  179. var mimetype = MIMETYPE[type] || false;
  180. if (text === undefined) {
  181. return process.bind(this, mimetype);
  182. }
  183. return process(mimetype, text);
  184. };
  185. this.getSpitor = function() {
  186. return SPLITOR;
  187. };
  188. this.getMimeType = function(sign) {
  189. if (sign !== undefined) {
  190. return SIGN[sign] || null;
  191. }
  192. return MIMETYPE;
  193. };
  194. }
  195. MimeType.prototype.isPureText = function(text) {
  196. return !~text.indexOf(this.getSpitor());
  197. };
  198. MimeType.prototype.getPureText = function(text) {
  199. if (this.isPureText(text)) {
  200. return text;
  201. }
  202. return text.split(this.getSpitor())[1];
  203. };
  204. MimeType.prototype.whichMimeType = function(text) {
  205. if (this.isPureText(text)) {
  206. return null;
  207. }
  208. return this.getMimeType(text.split(this.getSpitor())[0]);
  209. };
  210. function MimeTypeRuntime() {
  211. if (this.minder.supportClipboardEvent && !kity.Browser.gecko) {
  212. this.MimeType = new MimeType();
  213. }
  214. }
  215. return module.exports = MimeTypeRuntime;
  216. }
  217. };
  218. //src/runtime/clipboard.js
  219. /**
  220. * @Desc: 处理editor的clipboard事件,只在支持ClipboardEvent并且不是FF的情况下工作
  221. * @Editor: Naixor
  222. * @Date: 2015.9.21
  223. */
  224. _p[6] = {
  225. value: function(require, exports, module) {
  226. function ClipboardRuntime() {
  227. var minder = this.minder;
  228. var Data = window.kityminder.data;
  229. if (!minder.supportClipboardEvent || kity.Browser.gecko) {
  230. return;
  231. }
  232. var fsm = this.fsm;
  233. var receiver = this.receiver;
  234. var MimeType = this.MimeType;
  235. var kmencode = MimeType.getMimeTypeProtocol("application/km"), decode = Data.getRegisterProtocol("json").decode;
  236. var _selectedNodes = [];
  237. /*
  238. * 增加对多节点赋值粘贴的处理
  239. */
  240. function encode(nodes) {
  241. var _nodes = [];
  242. for (var i = 0, l = nodes.length; i < l; i++) {
  243. _nodes.push(minder.exportNode(nodes[i]));
  244. }
  245. return kmencode(Data.getRegisterProtocol("json").encode(_nodes));
  246. }
  247. var beforeCopy = function(e) {
  248. if (document.activeElement == receiver.element) {
  249. var clipBoardEvent = e;
  250. var state = fsm.state();
  251. switch (state) {
  252. case "input":
  253. {
  254. break;
  255. }
  256. case "normal":
  257. {
  258. var nodes = [].concat(minder.getSelectedNodes());
  259. if (nodes.length) {
  260. // 这里由于被粘贴复制的节点的id信息也都一样,故做此算法
  261. // 这里有个疑问,使用node.getParent()或者node.parent会离奇导致出现非选中节点被渲染成选中节点,因此使用isAncestorOf,而没有使用自行回溯的方式
  262. if (nodes.length > 1) {
  263. var targetLevel;
  264. nodes.sort(function(a, b) {
  265. return a.getLevel() - b.getLevel();
  266. });
  267. targetLevel = nodes[0].getLevel();
  268. if (targetLevel !== nodes[nodes.length - 1].getLevel()) {
  269. var plevel, pnode, idx = 0, l = nodes.length, pidx = l - 1;
  270. pnode = nodes[pidx];
  271. while (pnode.getLevel() !== targetLevel) {
  272. idx = 0;
  273. while (idx < l && nodes[idx].getLevel() === targetLevel) {
  274. if (nodes[idx].isAncestorOf(pnode)) {
  275. nodes.splice(pidx, 1);
  276. break;
  277. }
  278. idx++;
  279. }
  280. pidx--;
  281. pnode = nodes[pidx];
  282. }
  283. }
  284. }
  285. var str = encode(nodes);
  286. clipBoardEvent.clipboardData.setData("text/plain", str);
  287. }
  288. e.preventDefault();
  289. break;
  290. }
  291. }
  292. }
  293. };
  294. var beforeCut = function(e) {
  295. if (document.activeElement == receiver.element) {
  296. if (minder.getStatus() !== "normal") {
  297. e.preventDefault();
  298. return;
  299. }
  300. var clipBoardEvent = e;
  301. var state = fsm.state();
  302. switch (state) {
  303. case "input":
  304. {
  305. break;
  306. }
  307. case "normal":
  308. {
  309. var nodes = minder.getSelectedNodes();
  310. if (nodes.length) {
  311. clipBoardEvent.clipboardData.setData("text/plain", encode(nodes));
  312. minder.execCommand("removenode");
  313. }
  314. e.preventDefault();
  315. break;
  316. }
  317. }
  318. }
  319. };
  320. var beforePaste = function(e) {
  321. if (document.activeElement == receiver.element) {
  322. if (minder.getStatus() !== "normal") {
  323. e.preventDefault();
  324. return;
  325. }
  326. var clipBoardEvent = e;
  327. var state = fsm.state();
  328. var textData = clipBoardEvent.clipboardData.getData("text/plain");
  329. switch (state) {
  330. case "input":
  331. {
  332. // input状态下如果格式为application/km则不进行paste操作
  333. if (!MimeType.isPureText(textData)) {
  334. e.preventDefault();
  335. return;
  336. }
  337. break;
  338. }
  339. case "normal":
  340. {
  341. /*
  342. * 针对normal状态下通过对选中节点粘贴导入子节点文本进行单独处理
  343. */
  344. var sNodes = minder.getSelectedNodes();
  345. if (MimeType.whichMimeType(textData) === "application/km") {
  346. var nodes = decode(MimeType.getPureText(textData));
  347. var _node;
  348. sNodes.forEach(function(node) {
  349. // 由于粘贴逻辑中为了排除子节点重新排序导致逆序,因此复制的时候倒过来
  350. for (var i = nodes.length - 1; i >= 0; i--) {
  351. _node = minder.createNode(null, node);
  352. minder.importNode(_node, nodes[i]);
  353. _selectedNodes.push(_node);
  354. node.appendChild(_node);
  355. }
  356. });
  357. minder.select(_selectedNodes, true);
  358. _selectedNodes = [];
  359. minder.refresh();
  360. } else if (clipBoardEvent.clipboardData && clipBoardEvent.clipboardData.items[0].type.indexOf("image") > -1) {
  361. var imageFile = clipBoardEvent.clipboardData.items[0].getAsFile();
  362. var serverService = angular.element(document.body).injector().get("server");
  363. return serverService.uploadImage(imageFile).then(function(json) {
  364. var resp = json.data;
  365. if (resp.errno === 0) {
  366. minder.execCommand("image", resp.data.url);
  367. }
  368. });
  369. } else {
  370. sNodes.forEach(function(node) {
  371. minder.Text2Children(node, textData);
  372. });
  373. }
  374. e.preventDefault();
  375. break;
  376. }
  377. }
  378. }
  379. };
  380. /**
  381. * 由editor的receiver统一处理全部事件,包括clipboard事件
  382. * @Editor: Naixor
  383. * @Date: 2015.9.24
  384. */
  385. document.addEventListener("copy", beforeCopy);
  386. document.addEventListener("cut", beforeCut);
  387. document.addEventListener("paste", beforePaste);
  388. }
  389. return module.exports = ClipboardRuntime;
  390. }
  391. };
  392. //src/runtime/container.js
  393. /**
  394. * @fileOverview
  395. *
  396. * 初始化编辑器的容器
  397. *
  398. * @author: techird
  399. * @copyright: Baidu FEX, 2014
  400. */
  401. _p[7] = {
  402. value: function(require, exports, module) {
  403. /**
  404. * 最先执行的 Runtime,初始化编辑器容器
  405. */
  406. function ContainerRuntime() {
  407. var container;
  408. if (typeof this.selector == "string") {
  409. container = document.querySelector(this.selector);
  410. } else {
  411. container = this.selector;
  412. }
  413. if (!container) throw new Error("Invalid selector: " + this.selector);
  414. // 这个类名用于给编辑器添加样式
  415. container.classList.add("km-editor");
  416. // 暴露容器给其他运行时使用
  417. this.container = container;
  418. }
  419. return module.exports = ContainerRuntime;
  420. }
  421. };
  422. //src/runtime/drag.js
  423. /**
  424. * @fileOverview
  425. *
  426. * 用于拖拽节点时屏蔽键盘事件
  427. *
  428. * @author: techird
  429. * @copyright: Baidu FEX, 2014
  430. */
  431. _p[8] = {
  432. value: function(require, exports, module) {
  433. var Hotbox = _p.r(2);
  434. var Debug = _p.r(19);
  435. var debug = new Debug("drag");
  436. function DragRuntime() {
  437. var fsm = this.fsm;
  438. var minder = this.minder;
  439. var hotbox = this.hotbox;
  440. var receiver = this.receiver;
  441. var receiverElement = receiver.element;
  442. // setup everything to go
  443. setupFsm();
  444. // listen the fsm changes, make action.
  445. function setupFsm() {
  446. // when jumped to drag mode, enter
  447. fsm.when("* -> drag", function() {});
  448. fsm.when("drag -> *", function(exit, enter, reason) {
  449. if (reason == "drag-finish") {}
  450. });
  451. }
  452. var downX, downY;
  453. var MOUSE_HAS_DOWN = 0;
  454. var MOUSE_HAS_UP = 1;
  455. var BOUND_CHECK = 20;
  456. var flag = MOUSE_HAS_UP;
  457. var maxX, maxY, osx, osy, containerY;
  458. var freeHorizen = false, freeVirtical = false;
  459. var frame;
  460. function move(direction, speed) {
  461. if (!direction) {
  462. freeHorizen = freeVirtical = false;
  463. frame && kity.releaseFrame(frame);
  464. frame = null;
  465. return;
  466. }
  467. if (!frame) {
  468. frame = kity.requestFrame(function(direction, speed, minder) {
  469. return function(frame) {
  470. switch (direction) {
  471. case "left":
  472. minder._viewDragger.move({
  473. x: -speed,
  474. y: 0
  475. }, 0);
  476. break;
  477. case "top":
  478. minder._viewDragger.move({
  479. x: 0,
  480. y: -speed
  481. }, 0);
  482. break;
  483. case "right":
  484. minder._viewDragger.move({
  485. x: speed,
  486. y: 0
  487. }, 0);
  488. break;
  489. case "bottom":
  490. minder._viewDragger.move({
  491. x: 0,
  492. y: speed
  493. }, 0);
  494. break;
  495. default:
  496. return;
  497. }
  498. frame.next();
  499. };
  500. }(direction, speed, minder));
  501. }
  502. }
  503. minder.on("mousedown", function(e) {
  504. flag = MOUSE_HAS_DOWN;
  505. var rect = minder.getPaper().container.getBoundingClientRect();
  506. downX = e.originEvent.clientX;
  507. downY = e.originEvent.clientY;
  508. containerY = rect.top;
  509. maxX = rect.width;
  510. maxY = rect.height;
  511. });
  512. minder.on("mousemove", function(e) {
  513. if (fsm.state() === "drag" && flag == MOUSE_HAS_DOWN && minder.getSelectedNode() && (Math.abs(downX - e.originEvent.clientX) > BOUND_CHECK || Math.abs(downY - e.originEvent.clientY) > BOUND_CHECK)) {
  514. osx = e.originEvent.clientX;
  515. osy = e.originEvent.clientY - containerY;
  516. if (osx < BOUND_CHECK) {
  517. move("right", BOUND_CHECK - osx);
  518. } else if (osx > maxX - BOUND_CHECK) {
  519. move("left", BOUND_CHECK + osx - maxX);
  520. } else {
  521. freeHorizen = true;
  522. }
  523. if (osy < BOUND_CHECK) {
  524. move("bottom", osy);
  525. } else if (osy > maxY - BOUND_CHECK) {
  526. move("top", BOUND_CHECK + osy - maxY);
  527. } else {
  528. freeVirtical = true;
  529. }
  530. if (freeHorizen && freeVirtical) {
  531. move(false);
  532. }
  533. }
  534. if (fsm.state() !== "drag" && flag === MOUSE_HAS_DOWN && minder.getSelectedNode() && (Math.abs(downX - e.originEvent.clientX) > BOUND_CHECK || Math.abs(downY - e.originEvent.clientY) > BOUND_CHECK)) {
  535. if (fsm.state() === "hotbox") {
  536. hotbox.active(Hotbox.STATE_IDLE);
  537. }
  538. return fsm.jump("drag", "user-drag");
  539. }
  540. });
  541. window.addEventListener("mouseup", function() {
  542. flag = MOUSE_HAS_UP;
  543. if (fsm.state() === "drag") {
  544. move(false);
  545. return fsm.jump("normal", "drag-finish");
  546. }
  547. }, false);
  548. }
  549. return module.exports = DragRuntime;
  550. }
  551. };
  552. //src/runtime/fsm.js
  553. /**
  554. * @fileOverview
  555. *
  556. * 编辑器状态机
  557. *
  558. * @author: techird
  559. * @copyright: Baidu FEX, 2014
  560. */
  561. _p[9] = {
  562. value: function(require, exports, module) {
  563. var Debug = _p.r(19);
  564. var debug = new Debug("fsm");
  565. function handlerConditionMatch(condition, when, exit, enter) {
  566. if (condition.when != when) return false;
  567. if (condition.enter != "*" && condition.enter != enter) return false;
  568. if (condition.exit != "*" && condition.exit != exit) return;
  569. return true;
  570. }
  571. function FSM(defaultState) {
  572. var currentState = defaultState;
  573. var BEFORE_ARROW = " - ";
  574. var AFTER_ARROW = " -> ";
  575. var handlers = [];
  576. /**
  577. * 状态跳转
  578. *
  579. * 会通知所有的状态跳转监视器
  580. *
  581. * @param {string} newState 新状态名称
  582. * @param {any} reason 跳转的原因,可以作为参数传递给跳转监视器
  583. */
  584. this.jump = function(newState, reason) {
  585. if (!reason) throw new Error("Please tell fsm the reason to jump");
  586. var oldState = currentState;
  587. var notify = [ oldState, newState ].concat([].slice.call(arguments, 1));
  588. var i, handler;
  589. // 跳转前
  590. for (i = 0; i < handlers.length; i++) {
  591. handler = handlers[i];
  592. if (handlerConditionMatch(handler.condition, "before", oldState, newState)) {
  593. if (handler.apply(null, notify)) return;
  594. }
  595. }
  596. currentState = newState;
  597. debug.log("[{0}] {1} -> {2}", reason, oldState, newState);
  598. // 跳转后
  599. for (i = 0; i < handlers.length; i++) {
  600. handler = handlers[i];
  601. if (handlerConditionMatch(handler.condition, "after", oldState, newState)) {
  602. handler.apply(null, notify);
  603. }
  604. }
  605. return currentState;
  606. };
  607. /**
  608. * 返回当前状态
  609. * @return {string}
  610. */
  611. this.state = function() {
  612. return currentState;
  613. };
  614. /**
  615. * 添加状态跳转监视器
  616. *
  617. * @param {string} condition
  618. * 监视的时机
  619. * "* => *" (默认)
  620. *
  621. * @param {Function} handler
  622. * 监视函数,当状态跳转的时候,会接收三个参数
  623. * * from - 跳转前的状态
  624. * * to - 跳转后的状态
  625. * * reason - 跳转的原因
  626. */
  627. this.when = function(condition, handler) {
  628. if (arguments.length == 1) {
  629. handler = condition;
  630. condition = "* -> *";
  631. }
  632. var when, resolved, exit, enter;
  633. resolved = condition.split(BEFORE_ARROW);
  634. if (resolved.length == 2) {
  635. when = "before";
  636. } else {
  637. resolved = condition.split(AFTER_ARROW);
  638. if (resolved.length == 2) {
  639. when = "after";
  640. }
  641. }
  642. if (!when) throw new Error("Illegal fsm condition: " + condition);
  643. exit = resolved[0];
  644. enter = resolved[1];
  645. handler.condition = {
  646. when: when,
  647. exit: exit,
  648. enter: enter
  649. };
  650. handlers.push(handler);
  651. };
  652. }
  653. function FSMRumtime() {
  654. this.fsm = new FSM("normal");
  655. }
  656. return module.exports = FSMRumtime;
  657. }
  658. };
  659. //src/runtime/history.js
  660. /**
  661. * @fileOverview
  662. *
  663. * 历史管理
  664. *
  665. * @author: techird
  666. * @copyright: Baidu FEX, 2014
  667. */
  668. _p[10] = {
  669. value: function(require, exports, module) {
  670. var jsonDiff = _p.r(22);
  671. function HistoryRuntime() {
  672. var minder = this.minder;
  673. var hotbox = this.hotbox;
  674. var MAX_HISTORY = 100;
  675. var lastSnap;
  676. var patchLock;
  677. var undoDiffs;
  678. var redoDiffs;
  679. function reset() {
  680. undoDiffs = [];
  681. redoDiffs = [];
  682. lastSnap = minder.exportJson();
  683. }
  684. function makeUndoDiff() {
  685. var headSnap = minder.exportJson();
  686. var diff = jsonDiff(headSnap, lastSnap);
  687. if (diff.length) {
  688. undoDiffs.push(diff);
  689. while (undoDiffs.length > MAX_HISTORY) {
  690. undoDiffs.shift();
  691. }
  692. lastSnap = headSnap;
  693. return true;
  694. }
  695. }
  696. function makeRedoDiff() {
  697. var revertSnap = minder.exportJson();
  698. redoDiffs.push(jsonDiff(revertSnap, lastSnap));
  699. lastSnap = revertSnap;
  700. }
  701. function undo() {
  702. patchLock = true;
  703. var undoDiff = undoDiffs.pop();
  704. if (undoDiff) {
  705. minder.applyPatches(undoDiff);
  706. makeRedoDiff();
  707. }
  708. patchLock = false;
  709. }
  710. function redo() {
  711. patchLock = true;
  712. var redoDiff = redoDiffs.pop();
  713. if (redoDiff) {
  714. minder.applyPatches(redoDiff);
  715. makeUndoDiff();
  716. }
  717. patchLock = false;
  718. }
  719. function changed() {
  720. if (patchLock) return;
  721. if (makeUndoDiff()) redoDiffs = [];
  722. }
  723. function hasUndo() {
  724. return !!undoDiffs.length;
  725. }
  726. function hasRedo() {
  727. return !!redoDiffs.length;
  728. }
  729. function updateSelection(e) {
  730. if (!patchLock) return;
  731. var patch = e.patch;
  732. switch (patch.express) {
  733. case "node.add":
  734. minder.select(patch.node.getChild(patch.index), true);
  735. break;
  736. case "node.remove":
  737. case "data.replace":
  738. case "data.remove":
  739. case "data.add":
  740. minder.select(patch.node, true);
  741. break;
  742. }
  743. }
  744. this.history = {
  745. reset: reset,
  746. undo: undo,
  747. redo: redo,
  748. hasUndo: hasUndo,
  749. hasRedo: hasRedo
  750. };
  751. reset();
  752. minder.on("contentchange", changed);
  753. minder.on("import", reset);
  754. minder.on("patch", updateSelection);
  755. var main = hotbox.state("main");
  756. main.button({
  757. position: "top",
  758. label: "撤销",
  759. key: "Ctrl + Z",
  760. enable: hasUndo,
  761. action: undo,
  762. next: "idle"
  763. });
  764. main.button({
  765. position: "top",
  766. label: "重做",
  767. key: "Ctrl + Y",
  768. enable: hasRedo,
  769. action: redo,
  770. next: "idle"
  771. });
  772. }
  773. window.diff = jsonDiff;
  774. return module.exports = HistoryRuntime;
  775. }
  776. };
  777. //src/runtime/hotbox.js
  778. /**
  779. * @fileOverview
  780. *
  781. * 热盒 Runtime
  782. *
  783. * @author: techird
  784. * @copyright: Baidu FEX, 2014
  785. */
  786. _p[11] = {
  787. value: function(require, exports, module) {
  788. var Hotbox = _p.r(2);
  789. function HotboxRuntime() {
  790. var fsm = this.fsm;
  791. var minder = this.minder;
  792. var receiver = this.receiver;
  793. var container = this.container;
  794. var hotbox = new Hotbox(container);
  795. hotbox.setParentFSM(fsm);
  796. fsm.when("normal -> hotbox", function(exit, enter, reason) {
  797. var node = minder.getSelectedNode();
  798. var position;
  799. if (node) {
  800. var box = node.getRenderBox();
  801. position = {
  802. x: box.cx,
  803. y: box.cy
  804. };
  805. }
  806. hotbox.active("main", position);
  807. });
  808. fsm.when("normal -> normal", function(exit, enter, reason, e) {
  809. if (reason == "shortcut-handle") {
  810. var handleResult = hotbox.dispatch(e);
  811. if (handleResult) {
  812. e.preventDefault();
  813. } else {
  814. minder.dispatchKeyEvent(e);
  815. }
  816. }
  817. });
  818. fsm.when("modal -> normal", function(exit, enter, reason, e) {
  819. if (reason == "import-text-finish") {
  820. receiver.element.focus();
  821. }
  822. });
  823. this.hotbox = hotbox;
  824. }
  825. return module.exports = HotboxRuntime;
  826. }
  827. };
  828. //src/runtime/input.js
  829. /**
  830. * @fileOverview
  831. *
  832. * 文本输入支持
  833. *
  834. * @author: techird
  835. * @copyright: Baidu FEX, 2014
  836. */
  837. _p[12] = {
  838. value: function(require, exports, module) {
  839. _p.r(21);
  840. var Debug = _p.r(19);
  841. var debug = new Debug("input");
  842. function InputRuntime() {
  843. var fsm = this.fsm;
  844. var minder = this.minder;
  845. var hotbox = this.hotbox;
  846. var receiver = this.receiver;
  847. var receiverElement = receiver.element;
  848. var isGecko = window.kity.Browser.gecko;
  849. // setup everything to go
  850. setupReciverElement();
  851. setupFsm();
  852. setupHotbox();
  853. // expose editText()
  854. this.editText = editText;
  855. // listen the fsm changes, make action.
  856. function setupFsm() {
  857. // when jumped to input mode, enter
  858. fsm.when("* -> input", enterInputMode);
  859. // when exited, commit or exit depends on the exit reason
  860. fsm.when("input -> *", function(exit, enter, reason) {
  861. switch (reason) {
  862. case "input-cancel":
  863. return exitInputMode();
  864. case "input-commit":
  865. default:
  866. return commitInputResult();
  867. }
  868. });
  869. // lost focus to commit
  870. receiver.onblur(function(e) {
  871. if (fsm.state() == "input") {
  872. fsm.jump("normal", "input-commit");
  873. }
  874. });
  875. minder.on("beforemousedown", function() {
  876. if (fsm.state() == "input") {
  877. fsm.jump("normal", "input-commit");
  878. }
  879. });
  880. minder.on("dblclick", function() {
  881. if (minder.getSelectedNode() && minder._status !== "readonly") {
  882. editText();
  883. }
  884. });
  885. }
  886. // let the receiver follow the current selected node position
  887. function setupReciverElement() {
  888. if (debug.flaged) {
  889. receiverElement.classList.add("debug");
  890. }
  891. receiverElement.onmousedown = function(e) {
  892. e.stopPropagation();
  893. };
  894. minder.on("layoutallfinish viewchange viewchanged selectionchange", function(e) {
  895. // viewchange event is too frequenced, lazy it
  896. if (e.type == "viewchange" && fsm.state() != "input") return;
  897. updatePosition();
  898. });
  899. updatePosition();
  900. }
  901. // edit entrance in hotbox
  902. function setupHotbox() {
  903. hotbox.state("main").button({
  904. position: "center",
  905. label: "编辑",
  906. key: "F2",
  907. enable: function() {
  908. return minder.queryCommandState("text") != -1;
  909. },
  910. action: editText
  911. });
  912. }
  913. /**
  914. * 增加对字体的鉴别,以保证用户在编辑状态ctrl/cmd + b/i所触发的加粗斜体与显示一致
  915. * @editor Naixor
  916. * @Date 2015-12-2
  917. */
  918. // edit for the selected node
  919. function editText() {
  920. var node = minder.getSelectedNode();
  921. if (!node) {
  922. return;
  923. }
  924. var textContainer = receiverElement;
  925. receiverElement.innerText = "";
  926. if (node.getData("font-weight") === "bold") {
  927. var b = document.createElement("b");
  928. textContainer.appendChild(b);
  929. textContainer = b;
  930. }
  931. if (node.getData("font-style") === "italic") {
  932. var i = document.createElement("i");
  933. textContainer.appendChild(i);
  934. textContainer = i;
  935. }
  936. textContainer.innerText = minder.queryCommandValue("text");
  937. if (isGecko) {
  938. receiver.fixFFCaretDisappeared();
  939. }
  940. fsm.jump("input", "input-request");
  941. receiver.selectAll();
  942. }
  943. /**
  944. * 增加对字体的鉴别,以保证用户在编辑状态ctrl/cmd + b/i所触发的加粗斜体与显示一致
  945. * @editor Naixor
  946. * @Date 2015-12-2
  947. */
  948. function enterInputMode() {
  949. var node = minder.getSelectedNode();
  950. if (node) {
  951. var fontSize = node.getData("font-size") || node.getStyle("font-size");
  952. receiverElement.style.fontSize = fontSize + "px";
  953. receiverElement.style.minWidth = 0;
  954. receiverElement.style.minWidth = receiverElement.clientWidth + "px";
  955. receiverElement.style.fontWeight = node.getData("font-weight") || "";
  956. receiverElement.style.fontStyle = node.getData("font-style") || "";
  957. receiverElement.classList.add("input");
  958. receiverElement.focus();
  959. }
  960. }
  961. /**
  962. * 按照文本提交操作处理
  963. * @Desc: 从其他节点复制文字到另一个节点时部分浏览器(chrome)会自动包裹一个span标签,这样试用一下逻辑出来的就不是text节点二是span节点因此导致undefined的情况发生
  964. * @Warning: 下方代码使用[].slice.call来将HTMLDomCollection处理成为Array,ie8及以下会有问题
  965. * @Editor: Naixor
  966. * @Date: 2015.9.16
  967. */
  968. function commitInputText(textNodes) {
  969. var text = "";
  970. var TAB_CHAR = "\t", ENTER_CHAR = "\n", STR_CHECK = /\S/, SPACE_CHAR = " ", // 针对FF,SG,BD,LB,IE等浏览器下SPACE的charCode存在为32和160的情况做处理
  971. SPACE_CHAR_REGEXP = new RegExp("( |" + String.fromCharCode(160) + ")"), BR = document.createElement("br");
  972. var isBold = false, isItalic = false;
  973. for (var str, _divChildNodes, space_l, space_num, tab_num, i = 0, l = textNodes.length; i < l; i++) {
  974. str = textNodes[i];
  975. switch (Object.prototype.toString.call(str)) {
  976. // 正常情况处理
  977. case "[object HTMLBRElement]":
  978. {
  979. text += ENTER_CHAR;
  980. break;
  981. }
  982. case "[object Text]":
  983. {
  984. // SG下会莫名其妙的加上&nbsp;影响后续判断,干掉!
  985. /**
  986. * FF下的wholeText会导致如下问题:
  987. * |123| -> 在一个节点中输入一段字符,此时TextNode为[#Text 123]
  988. * 提交并重新编辑,在后面追加几个字符
  989. * |123abc| -> 此时123为一个TextNode为[#Text 123, #Text abc],但是对这两个任意取值wholeText均为全部内容123abc
  990. * 上述BUG仅存在在FF中,故将wholeText更改为textContent
  991. */
  992. str = str.textContent.replace("&nbsp;", " ");
  993. if (!STR_CHECK.test(str)) {
  994. space_l = str.length;
  995. while (space_l--) {
  996. if (SPACE_CHAR_REGEXP.test(str[space_l])) {
  997. text += SPACE_CHAR;
  998. } else if (str[space_l] === TAB_CHAR) {
  999. text += TAB_CHAR;
  1000. }
  1001. }
  1002. } else {
  1003. text += str;
  1004. }
  1005. break;
  1006. }
  1007. // ctrl + b/i 会给字体加上<b>/<i>标签来实现黑体和斜体
  1008. case "[object HTMLElement]":
  1009. {
  1010. switch (str.nodeName) {
  1011. case "B":
  1012. {
  1013. isBold = true;
  1014. break;
  1015. }
  1016. case "I":
  1017. {
  1018. isItalic = true;
  1019. break;
  1020. }
  1021. default:
  1022. {}
  1023. }
  1024. [].splice.apply(textNodes, [ i, 1 ].concat([].slice.call(str.childNodes)));
  1025. l = textNodes.length;
  1026. i--;
  1027. break;
  1028. }
  1029. // 被增加span标签的情况会被处理成正常情况并会推交给上面处理
  1030. case "[object HTMLSpanElement]":
  1031. {
  1032. [].splice.apply(textNodes, [ i, 1 ].concat([].slice.call(str.childNodes)));
  1033. l = textNodes.length;
  1034. i--;
  1035. break;
  1036. }
  1037. // 若标签为image标签,则判断是否为合法url,是将其加载进来
  1038. case "[object HTMLImageElement]":
  1039. {
  1040. if (str.src) {
  1041. if (/http(|s):\/\//.test(str.src)) {
  1042. minder.execCommand("Image", str.src, str.alt);
  1043. } else {}
  1044. }
  1045. break;
  1046. }
  1047. // 被增加div标签的情况会被处理成正常情况并会推交给上面处理
  1048. case "[object HTMLDivElement]":
  1049. {
  1050. _divChildNodes = [];
  1051. for (var di = 0, l = str.childNodes.length; di < l; di++) {
  1052. _divChildNodes.push(str.childNodes[di]);
  1053. }
  1054. _divChildNodes.push(BR);
  1055. [].splice.apply(textNodes, [ i, 1 ].concat(_divChildNodes));
  1056. l = textNodes.length;
  1057. i--;
  1058. break;
  1059. }
  1060. default:
  1061. {
  1062. if (str && str.childNodes.length) {
  1063. _divChildNodes = [];
  1064. for (var di = 0, l = str.childNodes.length; di < l; di++) {
  1065. _divChildNodes.push(str.childNodes[di]);
  1066. }
  1067. _divChildNodes.push(BR);
  1068. [].splice.apply(textNodes, [ i, 1 ].concat(_divChildNodes));
  1069. l = textNodes.length;
  1070. i--;
  1071. } else {
  1072. if (str && str.textContent !== undefined) {
  1073. text += str.textContent;
  1074. } else {
  1075. text += "";
  1076. }
  1077. }
  1078. }
  1079. }
  1080. }
  1081. text = text.replace(/^\n*|\n*$/g, "");
  1082. text = text.replace(new RegExp("(\n|\r|\n\r)( |" + String.fromCharCode(160) + "){4}", "g"), "$1\t");
  1083. minder.getSelectedNode().setText(text);
  1084. if (isBold) {
  1085. minder.queryCommandState("bold") || minder.execCommand("bold");
  1086. } else {
  1087. minder.queryCommandState("bold") && minder.execCommand("bold");
  1088. }
  1089. if (isItalic) {
  1090. minder.queryCommandState("italic") || minder.execCommand("italic");
  1091. } else {
  1092. minder.queryCommandState("italic") && minder.execCommand("italic");
  1093. }
  1094. exitInputMode();
  1095. return text;
  1096. }
  1097. /**
  1098. * 判断节点的文本信息是否是
  1099. * @Desc: 从其他节点复制文字到另一个节点时部分浏览器(chrome)会自动包裹一个span标签,这样使用以下逻辑出来的就不是text节点二是span节点因此导致undefined的情况发生
  1100. * @Notice: 此处逻辑应该拆分到 kityminder-core/core/data中去,单独增加一个对某个节点importJson的事件
  1101. * @Editor: Naixor
  1102. * @Date: 2015.9.16
  1103. */
  1104. function commitInputNode(node, text) {
  1105. try {
  1106. minder.decodeData("text", text).then(function(json) {
  1107. function importText(node, json, minder) {
  1108. var data = json.data;
  1109. node.setText(data.text || "");
  1110. var childrenTreeData = json.children || [];
  1111. for (var i = 0; i < childrenTreeData.length; i++) {
  1112. var childNode = minder.createNode(null, node);
  1113. importText(childNode, childrenTreeData[i], minder);
  1114. }
  1115. return node;
  1116. }
  1117. importText(node, json, minder);
  1118. minder.fire("contentchange");
  1119. minder.getRoot().renderTree();
  1120. minder.layout(300);
  1121. });
  1122. } catch (e) {
  1123. minder.fire("contentchange");
  1124. minder.getRoot().renderTree();
  1125. // 无法被转换成脑图节点则不处理
  1126. if (e.toString() !== "Error: Invalid local format") {
  1127. throw e;
  1128. }
  1129. }
  1130. }
  1131. function commitInputResult() {
  1132. /**
  1133. * @Desc: 进行如下处理:
  1134. * 根据用户的输入判断是否生成新的节点
  1135. * fix #83 https://github.com/fex-team/kityminder-editor/issues/83
  1136. * @Editor: Naixor
  1137. * @Date: 2015.9.16
  1138. */
  1139. var textNodes = [].slice.call(receiverElement.childNodes);
  1140. /**
  1141. * @Desc: 增加setTimeout的原因:ie下receiverElement.innerHTML=""会导致后
  1142. * 面commitInputText中使用textContent报错,不要问我什么原因!
  1143. * @Editor: Naixor
  1144. * @Date: 2015.12.14
  1145. */
  1146. setTimeout(function() {
  1147. // 解决过大内容导致SVG窜位问题
  1148. receiverElement.innerHTML = "";
  1149. }, 0);
  1150. var node = minder.getSelectedNode();
  1151. textNodes = commitInputText(textNodes);
  1152. commitInputNode(node, textNodes);
  1153. if (node.type == "root") {
  1154. var rootText = minder.getRoot().getText();
  1155. minder.fire("initChangeRoot", {
  1156. text: rootText
  1157. });
  1158. }
  1159. }
  1160. function exitInputMode() {
  1161. receiverElement.classList.remove("input");
  1162. receiver.selectAll();
  1163. }
  1164. function updatePosition() {
  1165. var planed = updatePosition;
  1166. var focusNode = minder.getSelectedNode();
  1167. if (!focusNode) return;
  1168. if (!planed.timer) {
  1169. planed.timer = setTimeout(function() {
  1170. var box = focusNode.getRenderBox("TextRenderer");
  1171. receiverElement.style.left = Math.round(box.x) + "px";
  1172. receiverElement.style.top = (debug.flaged ? Math.round(box.bottom + 30) : Math.round(box.y)) + "px";
  1173. //receiverElement.focus();
  1174. planed.timer = 0;
  1175. });
  1176. }
  1177. }
  1178. }
  1179. return module.exports = InputRuntime;
  1180. }
  1181. };
  1182. //src/runtime/jumping.js
  1183. /**
  1184. * @fileOverview
  1185. *
  1186. * 根据按键控制状态机的跳转
  1187. *
  1188. * @author: techird
  1189. * @copyright: Baidu FEX, 2014
  1190. */
  1191. _p[13] = {
  1192. value: function(require, exports, module) {
  1193. var Hotbox = _p.r(2);
  1194. // Nice: http://unixpapa.com/js/key.html
  1195. function isIntendToInput(e) {
  1196. if (e.ctrlKey || e.metaKey || e.altKey) return false;
  1197. // a-zA-Z
  1198. if (e.keyCode >= 65 && e.keyCode <= 90) return true;
  1199. // 0-9 以及其上面的符号
  1200. if (e.keyCode >= 48 && e.keyCode <= 57) return true;
  1201. // 小键盘区域 (除回车外)
  1202. if (e.keyCode != 108 && e.keyCode >= 96 && e.keyCode <= 111) return true;
  1203. // 小键盘区域 (除回车外)
  1204. // @yinheli from pull request
  1205. if (e.keyCode != 108 && e.keyCode >= 96 && e.keyCode <= 111) return true;
  1206. // 输入法
  1207. if (e.keyCode == 229 || e.keyCode === 0) return true;
  1208. return false;
  1209. }
  1210. /**
  1211. * @Desc: 下方使用receiver.enable()和receiver.disable()通过
  1212. * 修改div contenteditable属性的hack来解决开启热核后依然无法屏蔽浏览器输入的bug;
  1213. * 特别: win下FF对于此种情况必须要先blur在focus才能解决,但是由于这样做会导致用户
  1214. * 输入法状态丢失,因此对FF暂不做处理
  1215. * @Editor: Naixor
  1216. * @Date: 2015.09.14
  1217. */
  1218. function JumpingRuntime() {
  1219. var fsm = this.fsm;
  1220. var minder = this.minder;
  1221. var receiver = this.receiver;
  1222. var container = this.container;
  1223. var receiverElement = receiver.element;
  1224. var hotbox = this.hotbox;
  1225. var compositionLock = false;
  1226. // normal -> *
  1227. receiver.listen("normal", function(e) {
  1228. // 为了防止处理进入edit模式而丢失处理的首字母,此时receiver必须为enable
  1229. receiver.enable();
  1230. // normal -> hotbox
  1231. if (e.is("Space")) {
  1232. e.preventDefault();
  1233. // safari下Space触发hotbox,然而这时Space已在receiver上留下作案痕迹,因此抹掉
  1234. if (kity.Browser.safari) {
  1235. receiverElement.innerHTML = "";
  1236. }
  1237. return fsm.jump("hotbox", "space-trigger");
  1238. }
  1239. /**
  1240. * check
  1241. * @editor Naixor
  1242. * @Date 2015-12-2
  1243. */
  1244. switch (e.type) {
  1245. case "keydown":
  1246. {
  1247. if (minder.getSelectedNode()) {
  1248. if (isIntendToInput(e)) {
  1249. return fsm.jump("input", "user-input");
  1250. }
  1251. } else {
  1252. receiverElement.innerHTML = "";
  1253. }
  1254. // normal -> normal shortcut
  1255. fsm.jump("normal", "shortcut-handle", e);
  1256. break;
  1257. }
  1258. case "keyup":
  1259. {
  1260. break;
  1261. }
  1262. default:
  1263. {}
  1264. }
  1265. });
  1266. // hotbox -> normal
  1267. receiver.listen("hotbox", function(e) {
  1268. receiver.disable();
  1269. e.preventDefault();
  1270. var handleResult = hotbox.dispatch(e);
  1271. if (hotbox.state() == Hotbox.STATE_IDLE && fsm.state() == "hotbox") {
  1272. return fsm.jump("normal", "hotbox-idle");
  1273. }
  1274. });
  1275. // input => normal
  1276. receiver.listen("input", function(e) {
  1277. receiver.enable();
  1278. if (e.type == "keydown") {
  1279. if (e.is("Enter")) {
  1280. e.preventDefault();
  1281. return fsm.jump("normal", "input-commit");
  1282. }
  1283. if (e.is("Esc")) {
  1284. e.preventDefault();
  1285. return fsm.jump("normal", "input-cancel");
  1286. }
  1287. if (e.is("Tab") || e.is("Shift + Tab")) {
  1288. e.preventDefault();
  1289. }
  1290. } else if (e.type == "keyup" && e.is("Esc")) {
  1291. e.preventDefault();
  1292. if (!compositionLock) {
  1293. return fsm.jump("normal", "input-cancel");
  1294. }
  1295. } else if (e.type == "compositionstart") {
  1296. compositionLock = true;
  1297. } else if (e.type == "compositionend") {
  1298. setTimeout(function() {
  1299. compositionLock = false;
  1300. });
  1301. }
  1302. });
  1303. //////////////////////////////////////////////
  1304. /// 右键呼出热盒
  1305. /// 判断的标准是:按下的位置和结束的位置一致
  1306. //////////////////////////////////////////////
  1307. var downX, downY;
  1308. var MOUSE_RB = 2;
  1309. // 右键
  1310. container.addEventListener("mousedown", function(e) {
  1311. if (e.button == MOUSE_RB) {
  1312. e.preventDefault();
  1313. }
  1314. if (fsm.state() == "hotbox") {
  1315. hotbox.active(Hotbox.STATE_IDLE);
  1316. fsm.jump("normal", "blur");
  1317. } else if (fsm.state() == "normal" && e.button == MOUSE_RB) {
  1318. downX = e.clientX;
  1319. downY = e.clientY;
  1320. }
  1321. }, false);
  1322. container.addEventListener("mousewheel", function(e) {
  1323. if (fsm.state() == "hotbox") {
  1324. hotbox.active(Hotbox.STATE_IDLE);
  1325. fsm.jump("normal", "mousemove-blur");
  1326. }
  1327. }, false);
  1328. container.addEventListener("contextmenu", function(e) {
  1329. e.preventDefault();
  1330. });
  1331. container.addEventListener("mouseup", function(e) {
  1332. if (fsm.state() != "normal") {
  1333. return;
  1334. }
  1335. if (e.button != MOUSE_RB || e.clientX != downX || e.clientY != downY) {
  1336. return;
  1337. }
  1338. if (!minder.getSelectedNode()) {
  1339. return;
  1340. }
  1341. fsm.jump("hotbox", "content-menu");
  1342. }, false);
  1343. // 阻止热盒事件冒泡,在热盒正确执行前导致热盒关闭
  1344. hotbox.$element.addEventListener("mousedown", function(e) {
  1345. e.stopPropagation();
  1346. });
  1347. }
  1348. return module.exports = JumpingRuntime;
  1349. }
  1350. };
  1351. //src/runtime/minder.js
  1352. /**
  1353. * @fileOverview
  1354. *
  1355. * 脑图示例运行时
  1356. *
  1357. * @author: techird
  1358. * @copyright: Baidu FEX, 2014
  1359. */
  1360. _p[14] = {
  1361. value: function(require, exports, module) {
  1362. var Minder = _p.r(4);
  1363. function MinderRuntime() {
  1364. // 不使用 kityminder 的按键处理,由 ReceiverRuntime 统一处理
  1365. var minder = new Minder({
  1366. enableKeyReceiver: false,
  1367. enableAnimation: true
  1368. });
  1369. // 渲染,初始化
  1370. minder.renderTo(this.selector);
  1371. minder.setTheme(null);
  1372. minder.select(minder.getRoot(), true);
  1373. minder.execCommand("text", "中心主题");
  1374. // 导出给其它 Runtime 使用
  1375. this.minder = minder;
  1376. }
  1377. return module.exports = MinderRuntime;
  1378. }
  1379. };
  1380. //src/runtime/node.js
  1381. _p[15] = {
  1382. value: function(require, exports, module) {
  1383. function NodeRuntime() {
  1384. var runtime = this;
  1385. var minder = this.minder;
  1386. var hotbox = this.hotbox;
  1387. var fsm = this.fsm;
  1388. var main = hotbox.state("main");
  1389. var buttons = [ "前移:Alt+Up:ArrangeUp", "下级:Tab|Insert:AppendChildNode", "同级:Enter:AppendSiblingNode", "后移:Alt+Down:ArrangeDown", "删除:Delete|Backspace:RemoveNode", "上级:Shift+Tab|Shift+Insert:AppendParentNode" ];
  1390. var AppendLock = 0;
  1391. buttons.forEach(function(button) {
  1392. var parts = button.split(":");
  1393. var label = parts.shift();
  1394. var key = parts.shift();
  1395. var command = parts.shift();
  1396. main.button({
  1397. position: "ring",
  1398. label: label,
  1399. key: key,
  1400. action: function() {
  1401. if (command.indexOf("Append") === 0) {
  1402. AppendLock++;
  1403. minder.execCommand(command, "分支主题");
  1404. // provide in input runtime
  1405. function afterAppend() {
  1406. if (!--AppendLock) {
  1407. runtime.editText();
  1408. }
  1409. minder.off("layoutallfinish", afterAppend);
  1410. }
  1411. minder.on("layoutallfinish", afterAppend);
  1412. } else {
  1413. minder.execCommand(command);
  1414. fsm.jump("normal", "command-executed");
  1415. }
  1416. },
  1417. enable: function() {
  1418. return minder.queryCommandState(command) != -1;
  1419. }
  1420. });
  1421. });
  1422. main.button({
  1423. position: "bottom",
  1424. label: "导入节点",
  1425. key: "Alt + V",
  1426. enable: function() {
  1427. var selectedNodes = minder.getSelectedNodes();
  1428. return selectedNodes.length == 1;
  1429. },
  1430. action: importNodeData,
  1431. next: "idle"
  1432. });
  1433. main.button({
  1434. position: "bottom",
  1435. label: "导出节点",
  1436. key: "Alt + C",
  1437. enable: function() {
  1438. var selectedNodes = minder.getSelectedNodes();
  1439. return selectedNodes.length == 1;
  1440. },
  1441. action: exportNodeData,
  1442. next: "idle"
  1443. });
  1444. function importNodeData() {
  1445. minder.fire("importNodeData");
  1446. }
  1447. function exportNodeData() {
  1448. minder.fire("exportNodeData");
  1449. }
  1450. }
  1451. return module.exports = NodeRuntime;
  1452. }
  1453. };
  1454. //src/runtime/priority.js
  1455. _p[16] = {
  1456. value: function(require, exports, module) {
  1457. function PriorityRuntime() {
  1458. var minder = this.minder;
  1459. var hotbox = this.hotbox;
  1460. var main = hotbox.state("main");
  1461. main.button({
  1462. position: "top",
  1463. label: "优先级",
  1464. key: "P",
  1465. next: "priority",
  1466. enable: function() {
  1467. return minder.queryCommandState("priority") != -1;
  1468. }
  1469. });
  1470. var priority = hotbox.state("priority");
  1471. "123456789".replace(/./g, function(p) {
  1472. priority.button({
  1473. position: "ring",
  1474. label: "P" + p,
  1475. key: p,
  1476. action: function() {
  1477. minder.execCommand("Priority", p);
  1478. }
  1479. });
  1480. });
  1481. priority.button({
  1482. position: "center",
  1483. label: "移除",
  1484. key: "Del",
  1485. action: function() {
  1486. minder.execCommand("Priority", 0);
  1487. }
  1488. });
  1489. priority.button({
  1490. position: "top",
  1491. label: "返回",
  1492. key: "esc",
  1493. next: "back"
  1494. });
  1495. }
  1496. return module.exports = PriorityRuntime;
  1497. }
  1498. };
  1499. //src/runtime/progress.js
  1500. _p[17] = {
  1501. value: function(require, exports, module) {
  1502. function ProgressRuntime() {
  1503. var minder = this.minder;
  1504. var hotbox = this.hotbox;
  1505. var main = hotbox.state("main");
  1506. main.button({
  1507. position: "top",
  1508. label: "进度",
  1509. key: "G",
  1510. next: "progress",
  1511. enable: function() {
  1512. return minder.queryCommandState("progress") != -1;
  1513. }
  1514. });
  1515. var progress = hotbox.state("progress");
  1516. "012345678".replace(/./g, function(p) {
  1517. progress.button({
  1518. position: "ring",
  1519. label: "G" + p,
  1520. key: p,
  1521. action: function() {
  1522. minder.execCommand("Progress", parseInt(p) + 1);
  1523. }
  1524. });
  1525. });
  1526. progress.button({
  1527. position: "center",
  1528. label: "移除",
  1529. key: "Del",
  1530. action: function() {
  1531. minder.execCommand("Progress", 0);
  1532. }
  1533. });
  1534. progress.button({
  1535. position: "top",
  1536. label: "返回",
  1537. key: "esc",
  1538. next: "back"
  1539. });
  1540. }
  1541. return module.exports = ProgressRuntime;
  1542. }
  1543. };
  1544. //src/runtime/receiver.js
  1545. /**
  1546. * @fileOverview
  1547. *
  1548. * 键盘事件接收/分发器
  1549. *
  1550. * @author: techird
  1551. * @copyright: Baidu FEX, 2014
  1552. */
  1553. _p[18] = {
  1554. value: function(require, exports, module) {
  1555. var key = _p.r(23);
  1556. var hotbox = _p.r(2);
  1557. function ReceiverRuntime() {
  1558. var fsm = this.fsm;
  1559. var minder = this.minder;
  1560. var me = this;
  1561. // 接收事件的 div
  1562. var element = document.createElement("div");
  1563. element.contentEditable = true;
  1564. /**
  1565. * @Desc: 增加tabindex属性使得element的contenteditable不管是trur还是false都能有focus和blur事件
  1566. * @Editor: Naixor
  1567. * @Date: 2015.09.14
  1568. */
  1569. element.setAttribute("tabindex", -1);
  1570. element.classList.add("receiver");
  1571. element.onkeydown = element.onkeypress = element.onkeyup = dispatchKeyEvent;
  1572. element.addEventListener("compositionstart", dispatchKeyEvent);
  1573. // element.addEventListener('compositionend', dispatchKeyEvent);
  1574. this.container.appendChild(element);
  1575. // receiver 对象
  1576. var receiver = {
  1577. element: element,
  1578. selectAll: function() {
  1579. // 保证有被选中的
  1580. if (!element.innerHTML) element.innerHTML = "&nbsp;";
  1581. var range = document.createRange();
  1582. var selection = window.getSelection();
  1583. range.selectNodeContents(element);
  1584. selection.removeAllRanges();
  1585. selection.addRange(range);
  1586. element.focus();
  1587. },
  1588. /**
  1589. * @Desc: 增加enable和disable方法用于解决热核态的输入法屏蔽问题
  1590. * @Editor: Naixor
  1591. * @Date: 2015.09.14
  1592. */
  1593. enable: function() {
  1594. element.setAttribute("contenteditable", true);
  1595. },
  1596. disable: function() {
  1597. element.setAttribute("contenteditable", false);
  1598. },
  1599. /**
  1600. * @Desc: hack FF下div contenteditable的光标丢失BUG
  1601. * @Editor: Naixor
  1602. * @Date: 2015.10.15
  1603. */
  1604. fixFFCaretDisappeared: function() {
  1605. element.removeAttribute("contenteditable");
  1606. element.setAttribute("contenteditable", "true");
  1607. element.blur();
  1608. element.focus();
  1609. },
  1610. /**
  1611. * 以此事件代替通过mouse事件来判断receiver丢失焦点的事件
  1612. * @editor Naixor
  1613. * @Date 2015-12-2
  1614. */
  1615. onblur: function(handler) {
  1616. element.onblur = handler;
  1617. }
  1618. };
  1619. receiver.selectAll();
  1620. minder.on("beforemousedown", receiver.selectAll);
  1621. minder.on("receiverfocus", receiver.selectAll);
  1622. minder.on("readonly", function() {
  1623. // 屏蔽minder的事件接受,删除receiver和hotbox
  1624. minder.disable();
  1625. editor.receiver.element.parentElement.removeChild(editor.receiver.element);
  1626. editor.hotbox.$container.removeChild(editor.hotbox.$element);
  1627. });
  1628. // 侦听器,接收到的事件会派发给所有侦听器
  1629. var listeners = [];
  1630. // 侦听指定状态下的事件,如果不传 state,侦听所有状态
  1631. receiver.listen = function(state, listener) {
  1632. if (arguments.length == 1) {
  1633. listener = state;
  1634. state = "*";
  1635. }
  1636. listener.notifyState = state;
  1637. listeners.push(listener);
  1638. };
  1639. function dispatchKeyEvent(e) {
  1640. e.is = function(keyExpression) {
  1641. var subs = keyExpression.split("|");
  1642. for (var i = 0; i < subs.length; i++) {
  1643. if (key.is(this, subs[i])) return true;
  1644. }
  1645. return false;
  1646. };
  1647. var listener, jumpState;
  1648. for (var i = 0; i < listeners.length; i++) {
  1649. listener = listeners[i];
  1650. // 忽略不在侦听状态的侦听器
  1651. if (listener.notifyState != "*" && listener.notifyState != fsm.state()) {
  1652. continue;
  1653. }
  1654. /**
  1655. *
  1656. * 对于所有的侦听器,只允许一种处理方式:跳转状态。
  1657. * 如果侦听器确定要跳转,则返回要跳转的状态。
  1658. * 每个事件只允许一个侦听器进行状态跳转
  1659. * 跳转动作由侦听器自行完成(因为可能需要在跳转时传递 reason),返回跳转结果即可。
  1660. * 比如:
  1661. *
  1662. * ```js
  1663. * receiver.listen('normal', function(e) {
  1664. * if (isSomeReasonForJumpState(e)) {
  1665. * return fsm.jump('newstate', e);
  1666. * }
  1667. * });
  1668. * ```
  1669. */
  1670. if (listener.call(null, e)) {
  1671. return;
  1672. }
  1673. }
  1674. }
  1675. this.receiver = receiver;
  1676. }
  1677. return module.exports = ReceiverRuntime;
  1678. }
  1679. };
  1680. //src/tool/debug.js
  1681. /**
  1682. * @fileOverview
  1683. *
  1684. * 支持各种调试后门
  1685. *
  1686. * @author: techird
  1687. * @copyright: Baidu FEX, 2014
  1688. */
  1689. _p[19] = {
  1690. value: function(require, exports, module) {
  1691. var format = _p.r(20);
  1692. function noop() {}
  1693. function stringHash(str) {
  1694. var hash = 0;
  1695. for (var i = 0; i < str.length; i++) {
  1696. hash += str.charCodeAt(i);
  1697. }
  1698. return hash;
  1699. }
  1700. /* global console */
  1701. function Debug(flag) {
  1702. var debugMode = this.flaged = window.location.search.indexOf(flag) != -1;
  1703. if (debugMode) {
  1704. var h = stringHash(flag) % 360;
  1705. var flagStyle = format("background: hsl({0}, 50%, 80%); " + "color: hsl({0}, 100%, 30%); " + "padding: 2px 3px; " + "margin: 1px 3px 0 0;" + "border-radius: 2px;", h);
  1706. var textStyle = "background: none; color: black;";
  1707. this.log = function() {
  1708. var output = format.apply(null, arguments);
  1709. console.log(format("%c{0}%c{1}", flag, output), flagStyle, textStyle);
  1710. };
  1711. } else {
  1712. this.log = noop;
  1713. }
  1714. }
  1715. return module.exports = Debug;
  1716. }
  1717. };
  1718. //src/tool/format.js
  1719. _p[20] = {
  1720. value: function(require, exports, module) {
  1721. function format(template, args) {
  1722. if (typeof args != "object") {
  1723. args = [].slice.call(arguments, 1);
  1724. }
  1725. return String(template).replace(/\{(\w+)\}/gi, function(match, $key) {
  1726. return args[$key] || $key;
  1727. });
  1728. }
  1729. return module.exports = format;
  1730. }
  1731. };
  1732. //src/tool/innertext.js
  1733. /**
  1734. * @fileOverview
  1735. *
  1736. * innerText polyfill
  1737. *
  1738. * @author: techird
  1739. * @copyright: Baidu FEX, 2014
  1740. */
  1741. _p[21] = {
  1742. value: function(require, exports, module) {
  1743. if (!("innerText" in document.createElement("a")) && "getSelection" in window) {
  1744. HTMLElement.prototype.__defineGetter__("innerText", function() {
  1745. var selection = window.getSelection(), ranges = [], str, i;
  1746. // Save existing selections.
  1747. for (i = 0; i < selection.rangeCount; i++) {
  1748. ranges[i] = selection.getRangeAt(i);
  1749. }
  1750. // Deselect everything.
  1751. selection.removeAllRanges();
  1752. // Select `el` and all child nodes.
  1753. // 'this' is the element .innerText got called on
  1754. selection.selectAllChildren(this);
  1755. // Get the string representation of the selected nodes.
  1756. str = selection.toString();
  1757. // Deselect everything. Again.
  1758. selection.removeAllRanges();
  1759. // Restore all formerly existing selections.
  1760. for (i = 0; i < ranges.length; i++) {
  1761. selection.addRange(ranges[i]);
  1762. }
  1763. // Oh look, this is what we wanted.
  1764. // String representation of the element, close to as rendered.
  1765. return str;
  1766. });
  1767. HTMLElement.prototype.__defineSetter__("innerText", function(text) {
  1768. /**
  1769. * @Desc: 解决FireFox节点内容删除后text为null,出现报错的问题
  1770. * @Editor: Naixor
  1771. * @Date: 2015.9.16
  1772. */
  1773. this.innerHTML = (text || "").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<br>");
  1774. });
  1775. }
  1776. }
  1777. };
  1778. //src/tool/jsondiff.js
  1779. /**
  1780. * @fileOverview
  1781. *
  1782. *
  1783. *
  1784. * @author: techird
  1785. * @copyright: Baidu FEX, 2014
  1786. */
  1787. _p[22] = {
  1788. value: function(require, exports, module) {
  1789. /*!
  1790. * https://github.com/Starcounter-Jack/Fast-JSON-Patch
  1791. * json-patch-duplex.js 0.5.0
  1792. * (c) 2013 Joachim Wester
  1793. * MIT license
  1794. */
  1795. var _objectKeys = function() {
  1796. if (Object.keys) return Object.keys;
  1797. return function(o) {
  1798. var keys = [];
  1799. for (var i in o) {
  1800. if (o.hasOwnProperty(i)) {
  1801. keys.push(i);
  1802. }
  1803. }
  1804. return keys;
  1805. };
  1806. }();
  1807. function escapePathComponent(str) {
  1808. if (str.indexOf("/") === -1 && str.indexOf("~") === -1) return str;
  1809. return str.replace(/~/g, "~0").replace(/\//g, "~1");
  1810. }
  1811. function deepClone(obj) {
  1812. if (typeof obj === "object") {
  1813. return JSON.parse(JSON.stringify(obj));
  1814. } else {
  1815. return obj;
  1816. }
  1817. }
  1818. // Dirty check if obj is different from mirror, generate patches and update mirror
  1819. function _generate(mirror, obj, patches, path) {
  1820. var newKeys = _objectKeys(obj);
  1821. var oldKeys = _objectKeys(mirror);
  1822. var changed = false;
  1823. var deleted = false;
  1824. for (var t = oldKeys.length - 1; t >= 0; t--) {
  1825. var key = oldKeys[t];
  1826. var oldVal = mirror[key];
  1827. if (obj.hasOwnProperty(key)) {
  1828. var newVal = obj[key];
  1829. if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null) {
  1830. _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
  1831. } else {
  1832. if (oldVal != newVal) {
  1833. changed = true;
  1834. patches.push({
  1835. op: "replace",
  1836. path: path + "/" + escapePathComponent(key),
  1837. value: deepClone(newVal)
  1838. });
  1839. }
  1840. }
  1841. } else {
  1842. patches.push({
  1843. op: "remove",
  1844. path: path + "/" + escapePathComponent(key)
  1845. });
  1846. deleted = true;
  1847. }
  1848. }
  1849. if (!deleted && newKeys.length == oldKeys.length) {
  1850. return;
  1851. }
  1852. for (var t = 0; t < newKeys.length; t++) {
  1853. var key = newKeys[t];
  1854. if (!mirror.hasOwnProperty(key)) {
  1855. patches.push({
  1856. op: "add",
  1857. path: path + "/" + escapePathComponent(key),
  1858. value: deepClone(obj[key])
  1859. });
  1860. }
  1861. }
  1862. }
  1863. function compare(tree1, tree2) {
  1864. var patches = [];
  1865. _generate(tree1, tree2, patches, "");
  1866. return patches;
  1867. }
  1868. return module.exports = compare;
  1869. }
  1870. };
  1871. //src/tool/key.js
  1872. _p[23] = {
  1873. value: function(require, exports, module) {
  1874. var keymap = _p.r(24);
  1875. var CTRL_MASK = 4096;
  1876. var ALT_MASK = 8192;
  1877. var SHIFT_MASK = 16384;
  1878. function hash(unknown) {
  1879. if (typeof unknown == "string") {
  1880. return hashKeyExpression(unknown);
  1881. }
  1882. return hashKeyEvent(unknown);
  1883. }
  1884. function is(a, b) {
  1885. return a && b && hash(a) == hash(b);
  1886. }
  1887. exports.hash = hash;
  1888. exports.is = is;
  1889. function hashKeyEvent(keyEvent) {
  1890. var hashCode = 0;
  1891. if (keyEvent.ctrlKey || keyEvent.metaKey) {
  1892. hashCode |= CTRL_MASK;
  1893. }
  1894. if (keyEvent.altKey) {
  1895. hashCode |= ALT_MASK;
  1896. }
  1897. if (keyEvent.shiftKey) {
  1898. hashCode |= SHIFT_MASK;
  1899. }
  1900. // Shift, Control, Alt KeyCode ignored.
  1901. if ([ 16, 17, 18, 91 ].indexOf(keyEvent.keyCode) === -1) {
  1902. /**
  1903. * 解决浏览器输入法状态下对keyDown的keyCode判断不准确的问题,使用keyIdentifier,
  1904. * 可以解决chrome和safari下的各种问题,其他浏览器依旧有问题,然而那并不影响我们对特
  1905. * 需判断的按键进行判断(比如Space在safari输入法态下就是229,其他的就不是)
  1906. * @editor Naixor
  1907. * @Date 2015-12-2
  1908. */
  1909. if (keyEvent.keyCode === 229 && keyEvent.keyIdentifier) {
  1910. return hashCode |= parseInt(keyEvent.keyIdentifier.substr(2), 16);
  1911. }
  1912. hashCode |= keyEvent.keyCode;
  1913. }
  1914. return hashCode;
  1915. }
  1916. function hashKeyExpression(keyExpression) {
  1917. var hashCode = 0;
  1918. keyExpression.toLowerCase().split(/\s*\+\s*/).forEach(function(name) {
  1919. switch (name) {
  1920. case "ctrl":
  1921. case "cmd":
  1922. hashCode |= CTRL_MASK;
  1923. break;
  1924. case "alt":
  1925. hashCode |= ALT_MASK;
  1926. break;
  1927. case "shift":
  1928. hashCode |= SHIFT_MASK;
  1929. break;
  1930. default:
  1931. hashCode |= keymap[name];
  1932. }
  1933. });
  1934. return hashCode;
  1935. }
  1936. }
  1937. };
  1938. //src/tool/keymap.js
  1939. _p[24] = {
  1940. value: function(require, exports, module) {
  1941. var keymap = {
  1942. Shift: 16,
  1943. Control: 17,
  1944. Alt: 18,
  1945. CapsLock: 20,
  1946. BackSpace: 8,
  1947. Tab: 9,
  1948. Enter: 13,
  1949. Esc: 27,
  1950. Space: 32,
  1951. PageUp: 33,
  1952. PageDown: 34,
  1953. End: 35,
  1954. Home: 36,
  1955. Insert: 45,
  1956. Left: 37,
  1957. Up: 38,
  1958. Right: 39,
  1959. Down: 40,
  1960. Direction: {
  1961. 37: 1,
  1962. 38: 1,
  1963. 39: 1,
  1964. 40: 1
  1965. },
  1966. Del: 46,
  1967. NumLock: 144,
  1968. Cmd: 91,
  1969. CmdFF: 224,
  1970. F1: 112,
  1971. F2: 113,
  1972. F3: 114,
  1973. F4: 115,
  1974. F5: 116,
  1975. F6: 117,
  1976. F7: 118,
  1977. F8: 119,
  1978. F9: 120,
  1979. F10: 121,
  1980. F11: 122,
  1981. F12: 123,
  1982. "`": 192,
  1983. "=": 187,
  1984. "-": 189,
  1985. "/": 191,
  1986. ".": 190
  1987. };
  1988. // 小写适配
  1989. for (var key in keymap) {
  1990. if (keymap.hasOwnProperty(key)) {
  1991. keymap[key.toLowerCase()] = keymap[key];
  1992. }
  1993. }
  1994. var aKeyCode = 65;
  1995. var aCharCode = "a".charCodeAt(0);
  1996. // letters
  1997. "abcdefghijklmnopqrstuvwxyz".split("").forEach(function(letter) {
  1998. keymap[letter] = aKeyCode + (letter.charCodeAt(0) - aCharCode);
  1999. });
  2000. // numbers
  2001. var n = 9;
  2002. do {
  2003. keymap[n.toString()] = n + 48;
  2004. } while (--n);
  2005. module.exports = keymap;
  2006. }
  2007. };
  2008. var moduleMapping = {
  2009. "expose-editor": 1
  2010. };
  2011. function use(name) {
  2012. _p.r([ moduleMapping[name] ]);
  2013. }
  2014. angular.module('kityminderEditor', [
  2015. 'ui.bootstrap',
  2016. 'ui.codemirror',
  2017. 'ui.colorpicker'
  2018. ])
  2019. .config(["$sceDelegateProvider", function($sceDelegateProvider) {
  2020. $sceDelegateProvider.resourceUrlWhitelist([
  2021. // Allow same origin resource loads.
  2022. 'self',
  2023. // Allow loading from our assets domain. Notice the difference between * and **.
  2024. 'http://agroup.baidu.com:8910/**',
  2025. 'http://cq01-fe-rdtest01.vm.baidu.com:8910/**',
  2026. 'http://agroup.baidu.com:8911/**'
  2027. ]);
  2028. }]);
  2029. angular.module('kityminderEditor').run(['$templateCache', function($templateCache) {
  2030. 'use strict';
  2031. $templateCache.put('ui/directive/appendNode/appendNode.html',
  2032. "<div class=\"km-btn-group append-group\"><div class=\"km-btn-item append-child-node\" ng-disabled=\"minder.queryCommandState('AppendChildNode') === -1\" ng-click=\"minder.queryCommandState('AppendChildNode') === -1 || execCommand('AppendChildNode')\" title=\"{{ 'appendchildnode' | lang:'ui/command' }}\"><i class=\"km-btn-icon\"></i> <span class=\"km-btn-caption\">{{ 'appendchildnode' | lang:'ui/command' }}</span></div><div class=\"km-btn-item append-parent-node\" ng-disabled=\"minder.queryCommandState('AppendParentNode') === -1\" ng-click=\"minder.queryCommandState('AppendParentNode') === -1 || execCommand('AppendParentNode')\" title=\"{{ 'appendparentnode' | lang:'ui/command' }}\"><i class=\"km-btn-icon\"></i> <span class=\"km-btn-caption\">{{ 'appendparentnode' | lang:'ui/command' }}</span></div><div class=\"km-btn-item append-sibling-node\" ng-disabled=\"minder.queryCommandState('AppendSiblingNode') === -1\" ng-click=\"minder.queryCommandState('AppendSiblingNode') === -1 ||execCommand('AppendSiblingNode')\" title=\"{{ 'appendsiblingnode' | lang:'ui/command' }}\"><i class=\"km-btn-icon\"></i> <span class=\"km-btn-caption\">{{ 'appendsiblingnode' | lang:'ui/command' }}</span></div></div>"
  2033. );
  2034. $templateCache.put('ui/directive/arrange/arrange.html',
  2035. "<div class=\"km-btn-group arrange-group\"><div class=\"km-btn-item arrange-up\" ng-disabled=\"minder.queryCommandState('ArrangeUp') === -1\" ng-click=\"minder.queryCommandState('ArrangeUp') === -1 || minder.execCommand('ArrangeUp')\" title=\"{{ 'arrangeup' | lang:'ui/command' }}\"><i class=\"km-btn-icon\"></i> <span class=\"km-btn-caption\">{{ 'arrangeup' | lang:'ui/command' }}</span></div><div class=\"km-btn-item arrange-down\" ng-disabled=\"minder.queryCommandState('ArrangeDown') === -1\" ng-click=\"minder.queryCommandState('ArrangeDown') === -1 || minder.execCommand('ArrangeDown');\" title=\"{{ 'arrangedown' | lang:'ui/command' }}\"><i class=\"km-btn-icon\"></i> <span class=\"km-btn-caption\">{{ 'arrangedown' | lang:'ui/command' }}</span></div></div>"
  2036. );
  2037. $templateCache.put('ui/directive/colorPanel/colorPanel.html',
  2038. "<div class=\"bg-color-wrap\"><span class=\"quick-bg-color\" ng-click=\"minder.queryCommandState('background') === -1 || minder.execCommand('background', bgColor)\" ng-disabled=\"minder.queryCommandState('background') === -1\"></span> <span color-picker class=\"bg-color\" set-color=\"setDefaultBg()\" ng-disabled=\"minder.queryCommandState('background') === -1\"><span class=\"caret\"></span></span> <span class=\"bg-color-preview\" ng-style=\"{ 'background-color': bgColor }\" ng-click=\"minder.queryCommandState('background') === -1 || minder.execCommand('background', bgColor)\" ng-disabled=\"minder.queryCommandState('background') === -1\"></span></div>"
  2039. );
  2040. $templateCache.put('ui/directive/expandLevel/expandLevel.html',
  2041. "<div class=\"btn-group-vertical\" dropdown is-open=\"isopen\"><button type=\"button\" class=\"btn btn-default expand\" title=\"{{ 'expandtoleaf' | lang:'ui' }}\" ng-class=\"{'active': isopen}\" ng-click=\"minder.execCommand('ExpandToLevel', 9999)\"></button> <button type=\"button\" class=\"btn btn-default expand-caption dropdown-toggle\" title=\"{{ 'expandtoleaf' | lang:'ui' }}\" dropdown-toggle><span class=\"caption\">{{ 'expandtoleaf' | lang:'ui' }}</span> <span class=\"caret\"></span> <span class=\"sr-only\">{{ 'expandtoleaf' | lang:'ui' }}</span></button><ul class=\"dropdown-menu\" role=\"menu\"><li ng-repeat=\"level in levels\"><a href ng-click=\"minder.execCommand('ExpandToLevel', level)\">{{ 'expandtolevel' + level | lang:'ui/command' }}</a></li></ul></div>"
  2042. );
  2043. $templateCache.put('ui/directive/fontOperator/fontOperator.html',
  2044. "<div class=\"font-operator\"><div class=\"dropdown font-family-list\" dropdown><div class=\"dropdown-toggle current-font-item\" dropdown-toggle ng-disabled=\"minder.queryCommandState('fontfamily') === -1\"><a href class=\"current-font-family\" title=\"{{ 'fontfamily' | lang: 'ui' }}\">{{ getFontfamilyName(minder.queryCommandValue('fontfamily')) || '字体' }}</a> <span class=\"caret\"></span></div><ul class=\"dropdown-menu font-list\"><li ng-repeat=\"f in fontFamilyList\" class=\"font-item-wrap\"><a ng-click=\"minder.execCommand('fontfamily', f.val)\" class=\"font-item\" ng-class=\"{ 'font-item-selected' : f == minder.queryCommandValue('fontfamily') }\" ng-style=\"{'font-family': f.val }\">{{ f.name }}</a></li></ul></div><div class=\"dropdown font-size-list\" dropdown><div class=\"dropdown-toggle current-font-item\" dropdown-toggle ng-disabled=\"minder.queryCommandState('fontsize') === -1\"><a href class=\"current-font-size\" title=\"{{ 'fontsize' | lang: 'ui' }}\">{{ minder.queryCommandValue('fontsize') || '字号' }}</a> <span class=\"caret\"></span></div><ul class=\"dropdown-menu font-list\"><li ng-repeat=\"f in fontSizeList\" class=\"font-item-wrap\"><a ng-click=\"minder.execCommand('fontsize', f)\" class=\"font-item\" ng-class=\"{ 'font-item-selected' : f == minder.queryCommandValue('fontsize') }\" ng-style=\"{'font-size': f + 'px'}\">{{ f }}</a></li></ul></div><span class=\"s-btn-icon font-bold\" ng-click=\"minder.queryCommandState('bold') === -1 || minder.execCommand('bold')\" ng-class=\"{'font-bold-selected' : minder.queryCommandState('bold') == 1}\" ng-disabled=\"minder.queryCommandState('bold') === -1\"></span> <span class=\"s-btn-icon font-italics\" ng-click=\"minder.queryCommandState('italic') === -1 || minder.execCommand('italic')\" ng-class=\"{'font-italics-selected' : minder.queryCommandState('italic') == 1}\" ng-disabled=\"minder.queryCommandState('italic') === -1\"></span><div class=\"font-color-wrap\"><span class=\"quick-font-color\" ng-click=\"minder.queryCommandState('forecolor') === -1 || minder.execCommand('forecolor', foreColor)\" ng-disabled=\"minder.queryCommandState('forecolor') === -1\">A</span> <span color-picker class=\"font-color\" set-color=\"setDefaultColor()\" ng-disabled=\"minder.queryCommandState('forecolor') === -1\"><span class=\"caret\"></span></span> <span class=\"font-color-preview\" ng-style=\"{ 'background-color': foreColor }\" ng-click=\"minder.queryCommandState('forecolor') === -1 || minder.execCommand('forecolor', foreColor)\" ng-disabled=\"minder.queryCommandState('forecolor') === -1\"></span></div><color-panel minder=\"minder\" class=\"inline-directive\"></color-panel></div>"
  2045. );
  2046. $templateCache.put('ui/directive/hyperLink/hyperLink.html',
  2047. "<div class=\"btn-group-vertical\" dropdown is-open=\"isopen\"><button type=\"button\" class=\"btn btn-default hyperlink\" title=\"{{ 'link' | lang:'ui' }}\" ng-class=\"{'active': isopen}\" ng-click=\"addHyperlink()\" ng-disabled=\"minder.queryCommandState('HyperLink') === -1\"></button> <button type=\"button\" class=\"btn btn-default hyperlink-caption dropdown-toggle\" ng-disabled=\"minder.queryCommandState('HyperLink') === -1\" title=\"{{ 'link' | lang:'ui' }}\" dropdown-toggle><span class=\"caption\">{{ 'link' | lang:'ui' }}</span> <span class=\"caret\"></span> <span class=\"sr-only\">{{ 'link' | lang:'ui' }}</span></button><ul class=\"dropdown-menu\" role=\"menu\"><li><a href ng-click=\"addHyperlink()\">{{ 'insertlink' | lang:'ui' }}</a></li><li><a href ng-click=\"minder.execCommand('HyperLink', null)\">{{ 'removelink' | lang:'ui' }}</a></li></ul></div>"
  2048. );
  2049. $templateCache.put('ui/directive/imageBtn/imageBtn.html',
  2050. "<div class=\"btn-group-vertical\" dropdown is-open=\"isopen\"><button type=\"button\" class=\"btn btn-default image-btn\" title=\"{{ 'image' | lang:'ui' }}\" ng-class=\"{'active': isopen}\" ng-click=\"addImage()\" ng-disabled=\"minder.queryCommandState('Image') === -1\"></button> <button type=\"button\" class=\"btn btn-default image-btn-caption dropdown-toggle\" ng-disabled=\"minder.queryCommandState('Image') === -1\" title=\"{{ 'image' | lang:'ui' }}\" dropdown-toggle><span class=\"caption\">{{ 'image' | lang:'ui' }}</span> <span class=\"caret\"></span> <span class=\"sr-only\">{{ 'image' | lang:'ui' }}</span></button><ul class=\"dropdown-menu\" role=\"menu\"><li><a href ng-click=\"addImage()\">{{ 'insertimage' | lang:'ui' }}</a></li><li><a href ng-click=\"minder.execCommand('Image', '')\">{{ 'removeimage' | lang:'ui' }}</a></li></ul></div>"
  2051. );
  2052. $templateCache.put('ui/directive/kityminderEditor/kityminderEditor.html',
  2053. "<div class=\"minder-editor-container\"><div class=\"top-tab\" top-tab=\"minder\" editor=\"editor\" ng-if=\"minder\"></div><div search-box minder=\"minder\" ng-if=\"minder\"></div><div class=\"minder-editor\"></div><div class=\"km-note\" note-editor minder=\"minder\" ng-if=\"minder\"></div><div class=\"note-previewer\" note-previewer ng-if=\"minder\"></div><div class=\"navigator\" navigator minder=\"minder\" ng-if=\"minder\"></div></div>"
  2054. );
  2055. $templateCache.put('ui/directive/kityminderViewer/kityminderViewer.html',
  2056. "<div class=\"minder-editor-container\"><div class=\"minder-viewer\"></div><div class=\"note-previewer\" note-previewer ng-if=\"minder\"></div><div class=\"navigator\" navigator minder=\"minder\" ng-if=\"minder\"></div></div>"
  2057. );
  2058. $templateCache.put('ui/directive/layout/layout.html',
  2059. "<div class=\"readjust-layout\"><a ng-click=\"minder.queryCommandState('resetlayout') === -1 || minder.execCommand('resetlayout')\" class=\"btn-wrap\" ng-disabled=\"minder.queryCommandState('resetlayout') === -1\"><span class=\"btn-icon reset-layout-icon\"></span> <span class=\"btn-label\">{{ 'resetlayout' | lang: 'ui/command' }}</span></a></div>"
  2060. );
  2061. $templateCache.put('ui/directive/navigator/navigator.html',
  2062. "<div class=\"nav-bar\"><div class=\"nav-btn zoom-in\" ng-click=\"minder.execCommand('zoomIn')\" title=\"{{ 'zoom-in' | lang : 'ui' }}\" ng-class=\"{ 'active' : getZoomRadio(zoom) == 0 }\"><div class=\"icon\"></div></div><div class=\"zoom-pan\"><div class=\"origin\" ng-style=\"{'transform': 'translate(0, ' + getHeight(100) + 'px)'}\" ng-click=\"minder.execCommand('zoom', 100);\"></div><div class=\"indicator\" ng-style=\"{\r" +
  2063. "\n" +
  2064. " 'transform': 'translate(0, ' + getHeight(zoom) + 'px)',\r" +
  2065. "\n" +
  2066. " 'transition': 'transform 200ms'\r" +
  2067. "\n" +
  2068. " }\"></div></div><div class=\"nav-btn zoom-out\" ng-click=\"minder.execCommand('zoomOut')\" title=\"{{ 'zoom-out' | lang : 'ui' }}\" ng-class=\"{ 'active' : getZoomRadio(zoom) == 1 }\"><div class=\"icon\"></div></div><div class=\"nav-btn hand\" ng-click=\"minder.execCommand('hand')\" title=\"{{ 'hand' | lang : 'ui' }}\" ng-class=\"{ 'active' : minder.queryCommandState('hand') == 1 }\"><div class=\"icon\"></div></div><div class=\"nav-btn camera\" ng-click=\"minder.execCommand('camera', minder.getRoot(), 600);\" title=\"{{ 'camera' | lang : 'ui' }}\"><div class=\"icon\"></div></div><div class=\"nav-btn nav-trigger\" ng-class=\"{'active' : isNavOpen}\" ng-click=\"toggleNavOpen()\" title=\"{{ 'navigator' | lang : 'ui' }}\"><div class=\"icon\"></div></div></div><div class=\"nav-previewer\" ng-show=\"isNavOpen\"></div>"
  2069. );
  2070. $templateCache.put('ui/directive/noteBtn/noteBtn.html',
  2071. "<div class=\"btn-group-vertical note-btn-group\" dropdown is-open=\"isopen\"><button type=\"button\" class=\"btn btn-default note-btn\" title=\"{{ 'note' | lang:'ui' }}\" ng-class=\"{'active': isopen}\" ng-click=\"addNote()\" ng-disabled=\"minder.queryCommandState('note') === -1\"></button> <button type=\"button\" class=\"btn btn-default note-btn-caption dropdown-toggle\" ng-disabled=\"minder.queryCommandState('note') === -1\" title=\"{{ 'note' | lang:'ui' }}\" dropdown-toggle><span class=\"caption\">{{ 'note' | lang:'ui' }}</span> <span class=\"caret\"></span> <span class=\"sr-only\">{{ 'note' | lang:'ui' }}</span></button><ul class=\"dropdown-menu\" role=\"menu\"><li><a href ng-click=\"addNote()\">{{ 'insertnote' | lang:'ui' }}</a></li><li><a href ng-click=\"minder.execCommand('note', null)\">{{ 'removenote' | lang:'ui' }}</a></li></ul></div>"
  2072. );
  2073. $templateCache.put('ui/directive/noteEditor/noteEditor.html',
  2074. "<div class=\"panel panel-default\" ng-init=\"noteEditorOpen = false\" ng-show=\"noteEditorOpen\"><div class=\"panel-heading\"><h3 class=\"panel-title\">备注</h3><span>(<a class=\"help\" href=\"https://www.zybuluo.com/techird/note/46064\" target=\"_blank\">支持 GFM 语法书写</a>)</span> <i class=\"close-note-editor glyphicon glyphicon-remove\" ng-click=\"closeNoteEditor()\"></i></div><div class=\"panel-body\"><div ng-show=\"noteEnabled\" ui-codemirror=\"{ onLoad: codemirrorLoaded }\" ng-model=\"noteContent\" ui-codemirror-opts=\"{\r" +
  2075. "\n" +
  2076. " gfm: true,\r" +
  2077. "\n" +
  2078. " breaks: true,\r" +
  2079. "\n" +
  2080. " lineWrapping : true,\r" +
  2081. "\n" +
  2082. " mode: 'gfm',\r" +
  2083. "\n" +
  2084. " dragDrop: false,\r" +
  2085. "\n" +
  2086. " lineNumbers:true\r" +
  2087. "\n" +
  2088. " }\"></div><p ng-show=\"!noteEnabled\" class=\"km-note-tips\">请选择节点编辑备注</p></div></div>"
  2089. );
  2090. $templateCache.put('ui/directive/notePreviewer/notePreviewer.html',
  2091. "<div id=\"previewer-content\" ng-show=\"showNotePreviewer\" ng-style=\"previewerStyle\" ng-bind-html=\"noteContent\"></div>"
  2092. );
  2093. $templateCache.put('ui/directive/operation/operation.html',
  2094. "<div class=\"km-btn-group operation-group\"><div class=\"km-btn-item edit-node\" ng-disabled=\"minder.queryCommandState('text') === -1\" ng-click=\"minder.queryCommandState('text') === -1 || editNode()\" title=\"{{ 'editnode' | lang:'ui/command' }}\"><i class=\"km-btn-icon\"></i> <span class=\"km-btn-caption\">{{ 'editnode' | lang:'ui/command' }}</span></div><div class=\"km-btn-item remove-node\" ng-disabled=\"minder.queryCommandState('RemoveNode') === -1\" ng-click=\"minder.queryCommandState('RemoveNode') === -1 || minder.execCommand('RemoveNode');\" title=\"{{ 'removenode' | lang:'ui/command' }}\"><i class=\"km-btn-icon\"></i> <span class=\"km-btn-caption\">{{ 'removenode' | lang:'ui/command' }}</span></div></div>"
  2095. );
  2096. $templateCache.put('ui/directive/priorityEditor/priorityEditor.html',
  2097. "<ul class=\"km-priority tool-group\" ng-disabled=\"commandDisabled\"><li class=\"km-priority-item tool-group-item\" ng-repeat=\"p in priorities\" ng-click=\"commandDisabled || minder.execCommand('priority', p)\" ng-class=\"{ active: commandValue == p }\" title=\"{{ getPriorityTitle(p) }}\"><div class=\"km-priority-icon tool-group-icon priority-{{p}}\"></div></li></ul>"
  2098. );
  2099. $templateCache.put('ui/directive/progressEditor/progressEditor.html',
  2100. "<ul class=\"km-progress tool-group\" ng-disabled=\"commandDisabled\"><li class=\"km-progress-item tool-group-item\" ng-repeat=\"p in progresses\" ng-click=\"commandDisabled || minder.execCommand('progress', p)\" ng-class=\"{ active: commandValue == p }\" title=\"{{ getProgressTitle(p) }}\"><div class=\"km-progress-icon tool-group-icon progress-{{p}}\"></div></li></ul>"
  2101. );
  2102. $templateCache.put('ui/directive/resourceEditor/resourceEditor.html',
  2103. "<div class=\"resource-editor\"><div class=\"input-group\"><input class=\"form-control\" type=\"text\" ng-model=\"newResourceName\" ng-required ng-keypress=\"$event.keyCode == 13 && addResource(newResourceName)\" ng-disabled=\"!enabled\"> <span class=\"input-group-btn\"><button class=\"btn btn-default\" ng-click=\"addResource(newResourceName)\" ng-disabled=\"!enabled\">添加</button></span></div><div class=\"resource-dropdown clearfix\" id=\"resource-dropdown\"><ul class=\"km-resource\" ng-init=\"resourceListOpen = false\" ng-class=\"{'open': resourceListOpen}\"><li ng-repeat=\"resource in used\" ng-disabled=\"!enabled\" ng-blur=\"blurCB()\"><label style=\"background: {{resourceColor(resource.name)}}\"><input type=\"checkbox\" ng-model=\"resource.selected\" ng-disabled=\"!enabled\"> <span>{{resource.name}}</span></label></li></ul><div class=\"resource-caret\" click-anywhere-but-here=\"resourceListOpen = false\" is-active=\"resourceListOpen\" ng-click=\"resourceListOpen = !resourceListOpen\"><span class=\"caret\"></span></div></div></div>"
  2104. );
  2105. $templateCache.put('ui/directive/searchBox/searchBox.html',
  2106. "<div id=\"search\" class=\"search-box clearfix\" ng-show=\"showSearch\"><div class=\"input-group input-group-sm search-input-wrap\"><input type=\"text\" id=\"search-input\" class=\"form-control search-input\" ng-model=\"keyword\" ng-keydown=\"handleKeyDown($event)\" aria-describedby=\"basic-addon2\"> <span class=\"input-group-addon search-addon\" id=\"basic-addon2\" ng-show=\"showTip\" ng-bind=\"'第 ' + curIndex + ' 条,共 ' + resultNum + ' 条'\"></span></div><div class=\"btn-group btn-group-sm prev-and-next-btn\" role=\"group\"><button type=\"button\" class=\"btn btn-default\" ng-click=\"doSearch(keyword, 'prev')\"><span class=\"glyphicon glyphicon-chevron-up\"></span></button> <button type=\"button\" class=\"btn btn-default\" ng-click=\"doSearch(keyword, 'next')\"><span class=\"glyphicon glyphicon-chevron-down\"></span></button></div><div class=\"close-search\" ng-click=\"exitSearch()\"><span class=\"glyphicon glyphicon-remove\"></span></div></div>"
  2107. );
  2108. $templateCache.put('ui/directive/searchBtn/searchBtn.html',
  2109. "<div class=\"btn-group-vertical\" dropdown is-open=\"isopen\"><button type=\"button\" class=\"btn btn-default search\" title=\"{{ 'search' | lang:'ui' }}\" ng-class=\"{'active': isopen}\" ng-click=\"enterSearch()\"></button> <button type=\"button\" class=\"btn btn-default search-caption dropdown-toggle\" ng-click=\"enterSearch()\" title=\"{{ 'search' | lang:'ui' }}\"><span class=\"caption\">{{ 'search' | lang:'ui' }}</span> <span class=\"sr-only\">{{ 'search' | lang:'ui' }}</span></button></div>"
  2110. );
  2111. $templateCache.put('ui/directive/selectAll/selectAll.html',
  2112. "<div class=\"btn-group-vertical\" dropdown is-open=\"isopen\"><button type=\"button\" class=\"btn btn-default select\" title=\"{{ 'selectall' | lang:'ui' }}\" ng-class=\"{'active': isopen}\" ng-click=\"select['all']()\"></button> <button type=\"button\" class=\"btn btn-default select-caption dropdown-toggle\" title=\"{{ 'selectall' | lang:'ui' }}\" dropdown-toggle><span class=\"caption\">{{ 'selectall' | lang:'ui' }}</span> <span class=\"caret\"></span> <span class=\"sr-only\">{{ 'selectall' | lang:'ui' }}</span></button><ul class=\"dropdown-menu\" role=\"menu\"><li ng-repeat=\"item in items\"><a href ng-click=\"select[item]()\">{{ 'select' + item | lang:'ui' }}</a></li></ul></div>"
  2113. );
  2114. $templateCache.put('ui/directive/styleOperator/styleOperator.html',
  2115. "<div class=\"style-operator\"><a ng-click=\"minder.queryCommandState('clearstyle') === -1 || minder.execCommand('clearstyle')\" class=\"btn-wrap clear-style\" ng-disabled=\"minder.queryCommandState('clearstyle') === -1\"><span class=\"btn-icon clear-style-icon\"></span> <span class=\"btn-label\">{{ 'clearstyle' | lang: 'ui' }}</span></a><div class=\"s-btn-group-vertical\"><a class=\"s-btn-wrap\" href ng-click=\"minder.queryCommandState('copystyle') === -1 || minder.execCommand('copystyle')\" ng-disabled=\"minder.queryCommandState('copystyle') === -1\"><span class=\"s-btn-icon copy-style-icon\"></span> <span class=\"s-btn-label\">{{ 'copystyle' | lang: 'ui' }}</span></a> <a class=\"s-btn-wrap paste-style-wrap\" href ng-click=\"minder.queryCommandState('pastestyle') === -1 || minder.execCommand('pastestyle')\" ng-disabled=\"minder.queryCommandState('pastestyle') === -1\"><span class=\"s-btn-icon paste-style-icon\"></span> <span class=\"s-btn-label\">{{ 'pastestyle' | lang: 'ui' }}</span></a></div></div>"
  2116. );
  2117. $templateCache.put('ui/directive/templateList/templateList.html',
  2118. "<div class=\"dropdown temp-panel\" dropdown on-toggle=\"toggled(open)\"><div class=\"dropdown-toggle current-temp-item\" ng-disabled=\"minder.queryCommandState('template') === -1\" dropdown-toggle><a href class=\"temp-item {{ minder.queryCommandValue('template') }}\" title=\"{{ minder.queryCommandValue('template') | lang: 'template' }}\"></a> <span class=\"caret\"></span></div><ul class=\"dropdown-menu temp-list\"><li ng-repeat=\"(key, templateObj) in templateList\" class=\"temp-item-wrap\"><a ng-click=\"minder.execCommand('template', key);\" class=\"temp-item {{key}}\" ng-class=\"{ 'temp-item-selected' : key == minder.queryCommandValue('template') }\" title=\"{{ key | lang: 'template' }}\"></a></li></ul></div>"
  2119. );
  2120. $templateCache.put('ui/directive/themeList/themeList.html',
  2121. "<div class=\"dropdown theme-panel\" dropdown><div class=\"dropdown-toggle theme-item-selected\" dropdown-toggle ng-disabled=\"minder.queryCommandState('theme') === -1\"><a href class=\"theme-item\" ng-style=\"getThemeThumbStyle(minder.queryCommandValue('theme'))\" title=\"{{ minder.queryCommandValue('theme') | lang: 'theme'; }}\">{{ minder.queryCommandValue('theme') | lang: 'theme'; }}</a> <span class=\"caret\"></span></div><ul class=\"dropdown-menu theme-list\"><li ng-repeat=\"key in themeKeyList\" class=\"theme-item-wrap\"><a ng-click=\"minder.execCommand('theme', key);\" class=\"theme-item\" ng-style=\"getThemeThumbStyle(key)\" title=\"{{ key | lang: 'theme'; }}\">{{ key | lang: 'theme'; }}</a></li></ul></div>"
  2122. );
  2123. $templateCache.put('ui/directive/topTab/topTab.html',
  2124. "<tabset><tab heading=\"{{ 'idea' | lang: 'ui/tabs'; }}\" ng-click=\"toggleTopTab('idea')\" select=\"setCurTab('idea')\"><undo-redo editor=\"editor\"></undo-redo><append-node minder=\"minder\"></append-node><arrange minder=\"minder\"></arrange><operation minder=\"minder\"></operation><hyper-link minder=\"minder\"></hyper-link><image-btn minder=\"minder\"></image-btn><note-btn minder=\"minder\"></note-btn><priority-editor minder=\"minder\"></priority-editor><progress-editor minder=\"minder\"></progress-editor><resource-editor minder=\"minder\"></resource-editor></tab><tab heading=\"{{ 'appearence' | lang: 'ui/tabs'; }}\" ng-click=\"toggleTopTab('appearance')\" select=\"setCurTab('appearance')\"><template-list minder=\"minder\" class=\"inline-directive\"></template-list><theme-list minder=\"minder\"></theme-list><layout minder=\"minder\" class=\"inline-directive\"></layout><style-operator minder=\"minder\" class=\"inline-directive\"></style-operator><font-operator minder=\"minder\" class=\"inline-directive\"></font-operator></tab><tab heading=\"{{ 'view' | lang: 'ui/tabs'; }}\" ng-click=\"toggleTopTab('view')\" select=\"setCurTab('view')\"><expand-level minder=\"minder\"></expand-level><select-all minder=\"minder\"></select-all><search-btn minder=\"minder\"></search-btn></tab></tabset>"
  2125. );
  2126. $templateCache.put('ui/directive/undoRedo/undoRedo.html',
  2127. "<div class=\"km-btn-group do-group\"><div class=\"km-btn-item undo\" ng-disabled=\"editor.history.hasUndo() == false\" ng-click=\"editor.history.hasUndo() == false || editor.history.undo();\" title=\"{{ 'undo' | lang:'ui' }}\"><i class=\"km-btn-icon\"></i></div><div class=\"km-btn-item redo\" ng-disabled=\"editor.history.hasRedo() == false\" ng-click=\"editor.history.hasRedo() == false || editor.history.redo()\" title=\"{{ 'redo' | lang:'ui' }}\"><i class=\"km-btn-icon\"></i></div></div>"
  2128. );
  2129. $templateCache.put('ui/dialog/hyperlink/hyperlink.tpl.html',
  2130. "<div class=\"modal-header\"><h3 class=\"modal-title\">链接</h3></div><div class=\"modal-body\"><form><div class=\"form-group\" id=\"link-url-wrap\" ng-class=\"{true: 'has-success', false: 'has-error'}[urlPassed]\"><label for=\"link-url\">链接地址:</label><input type=\"text\" class=\"form-control\" ng-model=\"url\" ng-blur=\"urlPassed = R_URL.test(url)\" ng-focus=\"this.value = url\" ng-keydown=\"shortCut($event)\" id=\"link-url\" placeholder=\"必填:以 http(s):// 或 ftp:// 开头\"></div><div class=\"form-group\" ng-class=\"{'has-success' : titlePassed}\"><label for=\"link-title\">提示文本:</label><input type=\"text\" class=\"form-control\" ng-model=\"title\" ng-blur=\"titlePassed = true\" id=\"link-title\" placeholder=\"选填:鼠标在链接上悬停时提示的文本\"></div></form></div><div class=\"modal-footer\"><button class=\"btn btn-primary\" ng-click=\"ok()\">确定</button> <button class=\"btn btn-warning\" ng-click=\"cancel()\">取消</button></div>"
  2131. );
  2132. $templateCache.put('ui/dialog/imExportNode/imExportNode.tpl.html',
  2133. "<div class=\"modal-header\"><h3 class=\"modal-title\">{{ title }}</h3></div><div class=\"modal-body\"><textarea type=\"text\" class=\"form-control single-input\" rows=\"8\" ng-keydown=\"shortCut($event);\" ng-model=\"value\" ng-readonly=\"type === 'export'\">\r" +
  2134. "\n" +
  2135. " </textarea></div><div class=\"modal-footer\"><button class=\"btn btn-primary\" ng-click=\"ok()\" ng-disabled=\"type === 'import' && value == ''\">OK</button> <button class=\"btn btn-warning\" ng-click=\"cancel()\">Cancel</button></div>"
  2136. );
  2137. $templateCache.put('ui/dialog/image/image.tpl.html',
  2138. "<div class=\"modal-header\"><h3 class=\"modal-title\">图片</h3></div><div class=\"modal-body\"><tabset><tab heading=\"图片搜索\"><form class=\"form-inline\"><div class=\"form-group\"><label for=\"search-keyword\">关键词:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.searchKeyword2\" id=\"search-keyword\" placeholder=\"请输入搜索的关键词\"></div><button class=\"btn btn-primary\" ng-click=\"searchImage()\">百度一下</button></form><div class=\"search-result\" id=\"search-result\"><ul><li ng-repeat=\"image in list\" id=\"{{ 'img-item' + $index }}\" ng-class=\"{'selected' : isSelected}\" ng-click=\"selectImage($event)\"><img id=\"{{ 'img-' + $index }}\" ng-src=\"{{ image.src || '' }}\" alt=\"{{ image.title }}\" onerror=\"this.parentNode.removeChild(this)\"> <span>{{ image.title }}</span></li></ul></div></tab><tab heading=\"外链图片\"><form><div class=\"form-group\" ng-class=\"{true: 'has-success', false: 'has-error'}[urlPassed]\"><label for=\"image-url\">链接地址:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.url\" ng-blur=\"urlPassed = data.R_URL.test(data.url)\" ng-focus=\"this.value = data.url\" ng-keydown=\"shortCut($event)\" id=\"image-url\" placeholder=\"必填:以 http(s):// 开头\"></div><div class=\"form-group\" ng-class=\"{'has-success' : titlePassed}\"><label for=\"image-title\">提示文本:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.title\" ng-blur=\"titlePassed = true\" id=\"image-title\" placeholder=\"选填:鼠标在图片上悬停时提示的文本\"></div><div class=\"form-group\"><label for=\"image-preview\">图片预览:</label><img class=\"image-preview\" id=\"image-preview\" ng-src=\"{{ data.url }}\" alt=\"{{ data.title }}\"></div></form></tab><tab heading=\"上传图片\" active=\"true\"><form><div class=\"form-group\"><input type=\"file\" name=\"upload-image\" id=\"upload-image\" class=\"upload-image\" accept=\".jpg,.JPG,jpeg,JPEG,.png,.PNG,.gif,.GIF\" onchange=\"angular.element(this).scope().uploadImage()\"><label for=\"upload-image\" class=\"btn btn-primary\"><span>选择文件&hellip;</span></label></div><div class=\"form-group\" ng-class=\"{'has-success' : titlePassed}\"><label for=\"image-title\">提示文本:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.title\" ng-blur=\"titlePassed = true\" id=\"image-title\" placeholder=\"选填:鼠标在图片上悬停时提示的文本\"></div><div class=\"form-group\"><label for=\"image-preview\">图片预览:</label><img class=\"image-preview\" id=\"image-preview\" ng-src=\"{{ data.url }}\" title=\"{{ data.title }}\" alt=\"{{ data.title }}\"></div></form></tab></tabset></div><div class=\"modal-footer\"><button class=\"btn btn-primary\" ng-click=\"ok()\">确定</button> <button class=\"btn btn-warning\" ng-click=\"cancel()\">取消</button></div>"
  2139. );
  2140. }]);
  2141. angular.module('kityminderEditor').service('commandBinder', function() {
  2142. return {
  2143. bind: function(minder, command, scope) {
  2144. minder.on('interactchange', function() {
  2145. scope.commandDisabled = minder.queryCommandState(command) === -1;
  2146. scope.commandValue = minder.queryCommandValue(command);
  2147. scope.$apply();
  2148. });
  2149. }
  2150. };
  2151. });
  2152. angular.module('kityminderEditor')
  2153. .provider('config', function() {
  2154. this.config = {
  2155. // 右侧面板最小宽度
  2156. ctrlPanelMin: 250,
  2157. // 右侧面板宽度
  2158. ctrlPanelWidth: parseInt(window.localStorage.__dev_minder_ctrlPanelWidth) || 250,
  2159. // 分割线宽度
  2160. dividerWidth: 3,
  2161. // 默认语言
  2162. defaultLang: 'zh-cn',
  2163. // 放大缩小比例
  2164. zoom: [10, 20, 30, 50, 80, 100, 120, 150, 200],
  2165. // 图片上传接口
  2166. imageUpload: 'server/imageUpload.php'
  2167. };
  2168. this.set = function(key, value) {
  2169. var supported = Object.keys(this.config);
  2170. var configObj = {};
  2171. // 支持全配置
  2172. if (typeof key === 'object') {
  2173. configObj = key;
  2174. }
  2175. else {
  2176. configObj[key] = value;
  2177. }
  2178. for (var i in configObj) {
  2179. if (configObj.hasOwnProperty(i) && supported.indexOf(i) !== -1) {
  2180. this.config[i] = configObj[i];
  2181. }
  2182. else {
  2183. console.error('Unsupported config key: ', key, ', please choose in :', supported.join(', '));
  2184. return false;
  2185. }
  2186. }
  2187. return true;
  2188. };
  2189. this.$get = function () {
  2190. var me = this;
  2191. return {
  2192. get: function (key) {
  2193. if (arguments.length === 0) {
  2194. return me.config;
  2195. }
  2196. if (me.config.hasOwnProperty(key)) {
  2197. return me.config[key];
  2198. }
  2199. console.warn('Missing config key pair for : ', key);
  2200. return '';
  2201. }
  2202. };
  2203. }
  2204. });
  2205. angular.module('kityminderEditor')
  2206. .service('lang.zh-cn', function() {
  2207. return {
  2208. 'zh-cn': {
  2209. 'template': {
  2210. 'default': '思维导图',
  2211. 'tianpan': '天盘图',
  2212. 'structure': '组织结构图',
  2213. 'filetree': '目录组织图',
  2214. 'right': '逻辑结构图',
  2215. 'fish-bone': '鱼骨头图'
  2216. },
  2217. 'theme': {
  2218. 'classic': '脑图经典',
  2219. 'classic-compact': '紧凑经典',
  2220. 'snow': '温柔冷光',
  2221. 'snow-compact': '紧凑冷光',
  2222. 'fish': '鱼骨图',
  2223. 'wire': '线框',
  2224. 'fresh-red': '清新红',
  2225. 'fresh-soil': '泥土黄',
  2226. 'fresh-green': '文艺绿',
  2227. 'fresh-blue': '天空蓝',
  2228. 'fresh-purple': '浪漫紫',
  2229. 'fresh-pink': '脑残粉',
  2230. 'fresh-red-compat': '紧凑红',
  2231. 'fresh-soil-compat': '紧凑黄',
  2232. 'fresh-green-compat': '紧凑绿',
  2233. 'fresh-blue-compat': '紧凑蓝',
  2234. 'fresh-purple-compat': '紧凑紫',
  2235. 'fresh-pink-compat': '紧凑粉',
  2236. 'tianpan':'经典天盘',
  2237. 'tianpan-compact': '紧凑天盘'
  2238. },
  2239. 'maintopic': '中心主题',
  2240. 'topic': '分支主题',
  2241. 'panels': {
  2242. 'history': '历史',
  2243. 'template': '模板',
  2244. 'theme': '皮肤',
  2245. 'layout': '布局',
  2246. 'style': '样式',
  2247. 'font': '文字',
  2248. 'color': '颜色',
  2249. 'background': '背景',
  2250. 'insert': '插入',
  2251. 'arrange': '调整',
  2252. 'nodeop': '当前',
  2253. 'priority': '优先级',
  2254. 'progress': '进度',
  2255. 'resource': '资源',
  2256. 'note': '备注',
  2257. 'attachment': '附件',
  2258. 'word': '文字'
  2259. },
  2260. 'error_message': {
  2261. 'title': '哎呀,脑图出错了',
  2262. 'err_load': '加载脑图失败',
  2263. 'err_save': '保存脑图失败',
  2264. 'err_network': '网络错误',
  2265. 'err_doc_resolve': '文档解析失败',
  2266. 'err_unknown': '发生了奇怪的错误',
  2267. 'err_localfile_read': '文件读取错误',
  2268. 'err_download': '文件下载失败',
  2269. 'err_remove_share': '取消分享失败',
  2270. 'err_create_share': '分享失败',
  2271. 'err_mkdir': '目录创建失败',
  2272. 'err_ls': '读取目录失败',
  2273. 'err_share_data': '加载分享内容出错',
  2274. 'err_share_sync_fail': '分享内容同步失败',
  2275. 'err_move_file': '文件移动失败',
  2276. 'err_rename': '重命名失败',
  2277. 'unknownreason': '可能是外星人篡改了代码...',
  2278. 'pcs_code': {
  2279. 3: "不支持此接口",
  2280. 4: "没有权限执行此操作",
  2281. 5: "IP未授权",
  2282. 110: "用户会话已过期,请重新登录",
  2283. 31001: "数据库查询错误",
  2284. 31002: "数据库连接错误",
  2285. 31003: "数据库返回空结果",
  2286. 31021: "网络错误",
  2287. 31022: "暂时无法连接服务器",
  2288. 31023: "输入参数错误",
  2289. 31024: "app id为空",
  2290. 31025: "后端存储错误",
  2291. 31041: "用户的cookie不是合法的百度cookie",
  2292. 31042: "用户未登陆",
  2293. 31043: "用户未激活",
  2294. 31044: "用户未授权",
  2295. 31045: "用户不存在",
  2296. 31046: "用户已经存在",
  2297. 31061: "文件已经存在",
  2298. 31062: "文件名非法",
  2299. 31063: "文件父目录不存在",
  2300. 31064: "无权访问此文件",
  2301. 31065: "目录已满",
  2302. 31066: "文件不存在",
  2303. 31067: "文件处理出错",
  2304. 31068: "文件创建失败",
  2305. 31069: "文件拷贝失败",
  2306. 31070: "文件删除失败",
  2307. 31071: "不能读取文件元信息",
  2308. 31072: "文件移动失败",
  2309. 31073: "文件重命名失败",
  2310. 31079: "未找到文件MD5,请使用上传API上传整个文件。",
  2311. 31081: "superfile创建失败",
  2312. 31082: "superfile 块列表为空",
  2313. 31083: "superfile 更新失败",
  2314. 31101: "tag系统内部错误",
  2315. 31102: "tag参数错误",
  2316. 31103: "tag系统错误",
  2317. 31110: "未授权设置此目录配额",
  2318. 31111: "配额管理只支持两级目录",
  2319. 31112: "超出配额",
  2320. 31113: "配额不能超出目录祖先的配额",
  2321. 31114: "配额不能比子目录配额小",
  2322. 31141: "请求缩略图服务失败",
  2323. 31201: "签名错误",
  2324. 31202: "文件不存在",
  2325. 31203: "设置acl失败",
  2326. 31204: "请求acl验证失败",
  2327. 31205: "获取acl失败",
  2328. 31206: "acl不存在",
  2329. 31207: "bucket已存在",
  2330. 31208: "用户请求错误",
  2331. 31209: "服务器错误",
  2332. 31210: "服务器不支持",
  2333. 31211: "禁止访问",
  2334. 31212: "服务不可用",
  2335. 31213: "重试出错",
  2336. 31214: "上传文件data失败",
  2337. 31215: "上传文件meta失败",
  2338. 31216: "下载文件data失败",
  2339. 31217: "下载文件meta失败",
  2340. 31218: "容量超出限额",
  2341. 31219: "请求数超出限额",
  2342. 31220: "流量超出限额",
  2343. 31298: "服务器返回值KEY非法",
  2344. 31299: "服务器返回值KEY不存在"
  2345. }
  2346. },
  2347. 'ui': {
  2348. 'shared_file_title': '[分享的] {0} (只读)',
  2349. 'load_share_for_edit': '正在加载分享的文件...',
  2350. 'share_sync_success': '分享内容已同步',
  2351. 'recycle_clear_confirm': '确认清空回收站么?清空后的文件无法恢复。',
  2352. 'fullscreen_exit_hint': '按 Esc 或 F11 退出全屏',
  2353. 'error_detail': '详细信息',
  2354. 'copy_and_feedback': '复制并反馈',
  2355. 'move_file_confirm': '确定把 "{0}" 移动到 "{1}" 吗?',
  2356. 'rename': '重命名',
  2357. 'rename_success': '{0} 重命名成功',
  2358. 'move_success': '{0} 移动成功到 {1}',
  2359. 'command': {
  2360. 'appendsiblingnode': '插入同级主题',
  2361. 'appendparentnode': '插入上级主题',
  2362. 'appendchildnode': '插入下级主题',
  2363. 'removenode': '删除',
  2364. 'editnode': '编辑',
  2365. 'arrangeup': '上移',
  2366. 'arrangedown': '下移',
  2367. 'resetlayout': '整理布局',
  2368. 'expandtoleaf': '展开全部节点',
  2369. 'expandtolevel1': '展开到一级节点',
  2370. 'expandtolevel2': '展开到二级节点',
  2371. 'expandtolevel3': '展开到三级节点',
  2372. 'expandtolevel4': '展开到四级节点',
  2373. 'expandtolevel5': '展开到五级节点',
  2374. 'expandtolevel6': '展开到六级节点',
  2375. 'fullscreen': '全屏',
  2376. 'outline': '大纲'
  2377. },
  2378. 'search':'搜索',
  2379. 'expandtoleaf': '展开',
  2380. 'back': '返回',
  2381. 'undo': '撤销 (Ctrl + Z)',
  2382. 'redo': '重做 (Ctrl + Y)',
  2383. 'tabs': {
  2384. 'idea': '思路',
  2385. 'appearence': '外观',
  2386. 'view': '视图'
  2387. },
  2388. 'quickvisit': {
  2389. 'new': '新建 (Ctrl + Alt + N)',
  2390. 'save': '保存 (Ctrl + S)',
  2391. 'share': '分享 (Ctrl + Alt + S)',
  2392. 'feedback': '反馈问题(F1)',
  2393. 'editshare': '编辑'
  2394. },
  2395. 'menu': {
  2396. 'mainmenutext': '百度脑图', // 主菜单按钮文本
  2397. 'newtab': '新建',
  2398. 'opentab': '打开',
  2399. 'savetab': '保存',
  2400. 'sharetab': '分享',
  2401. 'preferencetab': '设置',
  2402. 'helptab': '帮助',
  2403. 'feedbacktab': '反馈',
  2404. 'recenttab': '最近使用',
  2405. 'netdisktab': '百度云存储',
  2406. 'localtab': '本地文件',
  2407. 'drafttab': '草稿箱',
  2408. 'downloadtab': '导出到本地',
  2409. 'createsharetab': '当前脑图',
  2410. 'managesharetab': '已分享',
  2411. 'newheader': '新建脑图',
  2412. 'openheader': '打开',
  2413. 'saveheader': '保存到',
  2414. 'draftheader': '草稿箱',
  2415. 'shareheader': '分享我的脑图',
  2416. 'downloadheader': '导出到指定格式',
  2417. 'preferenceheader': '偏好设置',
  2418. 'helpheader': '帮助',
  2419. 'feedbackheader': '反馈'
  2420. },
  2421. 'mydocument': '我的文档',
  2422. 'emptydir': '目录为空!',
  2423. 'pickfile': '选择文件...',
  2424. 'acceptfile': '支持的格式:{0}',
  2425. 'dropfile': '或将文件拖至此处',
  2426. 'unsupportedfile': '不支持的文件格式',
  2427. 'untitleddoc': '未命名文档',
  2428. 'overrideconfirm': '{0} 已存在,确认覆盖吗?',
  2429. 'checklogin': '检查登录状态中...',
  2430. 'loggingin': '正在登录...',
  2431. 'recent': '最近打开',
  2432. 'clearrecent': '清空',
  2433. 'clearrecentconfirm': '确认清空最近文档列表?',
  2434. 'cleardraft': '清空',
  2435. 'cleardraftconfirm': '确认清空草稿箱?',
  2436. 'none_share': '不分享',
  2437. 'public_share': '公开分享',
  2438. 'password_share': '私密分享',
  2439. 'email_share': '邮件邀请',
  2440. 'url_share': '脑图 URL 地址:',
  2441. 'sns_share': '社交网络分享:',
  2442. 'sns_share_text': '“{0}” - 我用百度脑图制作的思维导图,快看看吧!(地址:{1})',
  2443. 'none_share_description': '不分享当前脑图',
  2444. 'public_share_description': '创建任何人可见的分享',
  2445. 'share_button_text': '创建',
  2446. 'password_share_description': '创建需要密码才可见的分享',
  2447. 'email_share_description': '创建指定人可见的分享,您还可以允许他们编辑',
  2448. 'ondev': '敬请期待!',
  2449. 'create_share_failed': '分享失败:{0}',
  2450. 'remove_share_failed': '删除失败:{1}',
  2451. 'copy': '复制',
  2452. 'copied': '已复制',
  2453. 'shared_tip': '当前脑图被 {0} 分享,你可以修改之后保存到自己的网盘上或再次分享',
  2454. 'current_share': '当前脑图',
  2455. 'manage_share': '我的分享',
  2456. 'share_remove_action': '不分享该脑图',
  2457. 'share_view_action': '打开分享地址',
  2458. 'share_edit_action': '编辑分享的文件',
  2459. 'login': '登录',
  2460. 'logout': '注销',
  2461. 'switchuser': '切换账户',
  2462. 'userinfo': '个人信息',
  2463. 'gotonetdisk': '我的网盘',
  2464. 'requirelogin': '请 <a class="login-button">登录</a> 后使用',
  2465. 'saveas': '保存为',
  2466. 'filename': '文件名',
  2467. 'fileformat': '保存格式',
  2468. 'save': '保存',
  2469. 'mkdir': '新建目录',
  2470. 'recycle': '回收站',
  2471. 'newdir': '未命名目录',
  2472. 'bold': '加粗',
  2473. 'italic': '斜体',
  2474. 'forecolor': '字体颜色',
  2475. 'fontfamily': '字体',
  2476. 'fontsize': '字号',
  2477. 'layoutstyle': '主题',
  2478. 'node': '节点操作',
  2479. 'saveto': '另存为',
  2480. 'hand': '允许拖拽',
  2481. 'camera': '定位根节点',
  2482. 'zoom-in': '放大(Ctrl+)',
  2483. 'zoom-out': '缩小(Ctrl-)',
  2484. 'markers': '标签',
  2485. 'resource': '资源',
  2486. 'help': '帮助',
  2487. 'preference': '偏好设置',
  2488. 'expandnode': '展开到叶子',
  2489. 'collapsenode': '收起到一级节点',
  2490. 'template': '模板',
  2491. 'theme': '皮肤',
  2492. 'clearstyle': '清除样式',
  2493. 'copystyle': '复制样式',
  2494. 'pastestyle': '粘贴样式',
  2495. 'appendsiblingnode': '同级主题',
  2496. 'appendchildnode': '下级主题',
  2497. 'arrangeup': '前调',
  2498. 'arrangedown': '后调',
  2499. 'editnode': '编辑',
  2500. 'removenode': '移除',
  2501. 'priority': '优先级',
  2502. 'progress': {
  2503. 'p1': '未开始',
  2504. 'p2': '完成 1/8',
  2505. 'p3': '完成 1/4',
  2506. 'p4': '完成 3/8',
  2507. 'p5': '完成一半',
  2508. 'p6': '完成 5/8',
  2509. 'p7': '完成 3/4',
  2510. 'p8': '完成 7/8',
  2511. 'p9': '已完成',
  2512. 'p0': '清除进度'
  2513. },
  2514. 'link': '链接',
  2515. 'image': '图片',
  2516. 'note': '备注',
  2517. 'insertlink': '插入链接',
  2518. 'insertimage': '插入图片',
  2519. 'insertnote': '插入备注',
  2520. 'removelink': '移除已有链接',
  2521. 'removeimage': '移除已有图片',
  2522. 'removenote': '移除已有备注',
  2523. 'resetlayout': '整理',
  2524. 'justnow': '刚刚',
  2525. 'minutesago': '{0} 分钟前',
  2526. 'hoursago': '{0} 小时前',
  2527. 'yesterday': '昨天',
  2528. 'daysago': '{0} 天前',
  2529. 'longago': '很久之前',
  2530. 'redirect': '您正在打开连接 {0},百度脑图不能保证连接的安全性,是否要继续?',
  2531. 'navigator': '导航器',
  2532. 'unsavedcontent': '当前文件还没有保存到网盘:\n\n{0}\n\n虽然未保存的数据会缓存在草稿箱,但是清除浏览器缓存会导致草稿箱清除。',
  2533. 'shortcuts': '快捷键',
  2534. 'contact': '联系与反馈',
  2535. 'email': '邮件组',
  2536. 'qq_group': 'QQ 群',
  2537. 'github_issue': 'Github',
  2538. 'baidu_tieba': '贴吧',
  2539. 'clipboardunsupported': '您的浏览器不支持剪贴板,请使用快捷键复制',
  2540. 'load_success': '{0} 加载成功',
  2541. 'save_success': '{0} 已保存于 {1}',
  2542. 'autosave_success': '{0} 已自动保存于 {1}',
  2543. 'selectall': '全选',
  2544. 'selectrevert': '反选',
  2545. 'selectsiblings': '选择兄弟节点',
  2546. 'selectlevel': '选择同级节点',
  2547. 'selectpath': '选择路径',
  2548. 'selecttree': '选择子树'
  2549. },
  2550. 'popupcolor': {
  2551. 'clearColor': '清空颜色',
  2552. 'standardColor': '标准颜色',
  2553. 'themeColor': '主题颜色'
  2554. },
  2555. 'dialogs': {
  2556. 'markers': {
  2557. 'static': {
  2558. 'lang_input_text': '文本内容:',
  2559. 'lang_input_url': '链接地址:',
  2560. 'lang_input_title': '标题:',
  2561. 'lang_input_target': '是否在新窗口:'
  2562. },
  2563. 'priority': '优先级',
  2564. 'none': '无',
  2565. 'progress': {
  2566. 'title': '进度',
  2567. 'notdone': '未完成',
  2568. 'done1': '完成 1/8',
  2569. 'done2': '完成 1/4',
  2570. 'done3': '完成 3/8',
  2571. 'done4': '完成 1/2',
  2572. 'done5': '完成 5/8',
  2573. 'done6': '完成 3/4',
  2574. 'done7': '完成 7/8',
  2575. 'done': '已完成'
  2576. }
  2577. },
  2578. 'help': {
  2579. },
  2580. 'hyperlink': {},
  2581. 'image': {},
  2582. 'resource': {}
  2583. },
  2584. 'hyperlink': {
  2585. 'hyperlink': '链接...',
  2586. 'unhyperlink': '移除链接'
  2587. },
  2588. 'image': {
  2589. 'image': '图片...',
  2590. 'removeimage': '移除图片'
  2591. },
  2592. 'marker': {
  2593. 'marker': '进度/优先级...'
  2594. },
  2595. 'resource': {
  2596. 'resource': '资源...'
  2597. }
  2598. }
  2599. }
  2600. });
  2601. /**
  2602. * @fileOverview
  2603. *
  2604. * UI 状态的 LocalStorage 的存取文件,未来可能在离线编辑的时候升级
  2605. *
  2606. * @author: zhangbobell
  2607. * @email : zhangbobell@163.com
  2608. *
  2609. * @copyright: Baidu FEX, 2015
  2610. */
  2611. angular.module('kityminderEditor')
  2612. .service('memory', function() {
  2613. function isQuotaExceeded(e) {
  2614. var quotaExceeded = false;
  2615. if (e) {
  2616. if (e.code) {
  2617. switch (e.code) {
  2618. case 22:
  2619. quotaExceeded = true;
  2620. break;
  2621. case 1014:
  2622. // Firefox
  2623. if (e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {
  2624. quotaExceeded = true;
  2625. }
  2626. break;
  2627. }
  2628. } else if (e.number === -2147024882) {
  2629. // Internet Explorer 8
  2630. quotaExceeded = true;
  2631. }
  2632. }
  2633. return quotaExceeded;
  2634. }
  2635. return {
  2636. get: function(key) {
  2637. var value = window.localStorage.getItem(key);
  2638. return null || JSON.parse(value);
  2639. },
  2640. set: function(key, value) {
  2641. try {
  2642. window.localStorage.setItem(key, JSON.stringify(value));
  2643. return true;
  2644. } catch(e) {
  2645. if (isQuotaExceeded(e)) {
  2646. return false;
  2647. }
  2648. }
  2649. },
  2650. remove: function(key) {
  2651. var value = window.localStorage.getItem(key);
  2652. window.localStorage.removeItem(key);
  2653. return value;
  2654. },
  2655. clear: function() {
  2656. window.localStorage.clear();
  2657. }
  2658. }
  2659. });
  2660. angular.module('kityminderEditor')
  2661. .service('minder.service', function() {
  2662. var callbackQueue = [];
  2663. function registerEvent(callback) {
  2664. callbackQueue.push(callback);
  2665. }
  2666. function executeCallback() {
  2667. callbackQueue.forEach(function(ele) {
  2668. ele.apply(this, arguments);
  2669. })
  2670. }
  2671. return {
  2672. registerEvent: registerEvent,
  2673. executeCallback: executeCallback
  2674. }
  2675. });
  2676. angular.module('kityminderEditor')
  2677. .service('resourceService', ['$document', function($document) {
  2678. var openScope = null;
  2679. this.open = function( dropdownScope ) {
  2680. if ( !openScope ) {
  2681. $document.bind('click', closeDropdown);
  2682. $document.bind('keydown', escapeKeyBind);
  2683. }
  2684. if ( openScope && openScope !== dropdownScope ) {
  2685. openScope.resourceListOpen = false;
  2686. }
  2687. openScope = dropdownScope;
  2688. };
  2689. this.close = function( dropdownScope ) {
  2690. if ( openScope === dropdownScope ) {
  2691. openScope = null;
  2692. $document.unbind('click', closeDropdown);
  2693. $document.unbind('keydown', escapeKeyBind);
  2694. }
  2695. };
  2696. var closeDropdown = function( evt ) {
  2697. // This method may still be called during the same mouse event that
  2698. // unbound this event handler. So check openScope before proceeding.
  2699. //console.log(evt, openScope);
  2700. if (!openScope) { return; }
  2701. var toggleElement = openScope.getToggleElement();
  2702. if ( evt && toggleElement && toggleElement[0].contains(evt.target) ) {
  2703. return;
  2704. }
  2705. openScope.$apply(function() {
  2706. console.log('to close the resourcelist');
  2707. openScope.resourceListOpen = false;
  2708. });
  2709. };
  2710. var escapeKeyBind = function( evt ) {
  2711. if ( evt.which === 27 ) {
  2712. openScope.focusToggleElement();
  2713. closeDropdown();
  2714. }
  2715. };
  2716. }])
  2717. angular.module('kityminderEditor').service('revokeDialog', ['$modal', 'minder.service', function($modal, minderService) {
  2718. minderService.registerEvent(function() {
  2719. // 触发导入节点或导出节点对话框
  2720. var minder = window.minder;
  2721. var editor = window.editor;
  2722. var parentFSM = editor.hotbox.getParentFSM();
  2723. minder.on('importNodeData', function() {
  2724. parentFSM.jump('modal', 'import-text-modal');
  2725. var importModal = $modal.open({
  2726. animation: true,
  2727. templateUrl: 'ui/dialog/imExportNode/imExportNode.tpl.html',
  2728. controller: 'imExportNode.ctrl',
  2729. size: 'md',
  2730. resolve: {
  2731. title: function() {
  2732. return '导入节点';
  2733. },
  2734. defaultValue: function() {
  2735. return '';
  2736. },
  2737. type: function() {
  2738. return 'import';
  2739. }
  2740. }
  2741. });
  2742. importModal.result.then(function(result) {
  2743. try{
  2744. minder.Text2Children(minder.getSelectedNode(), result);
  2745. } catch(e) {
  2746. alert(e);
  2747. }
  2748. parentFSM.jump('normal', 'import-text-finish');
  2749. editor.receiver.selectAll();
  2750. }, function() {
  2751. parentFSM.jump('normal', 'import-text-finish');
  2752. editor.receiver.selectAll();
  2753. });
  2754. });
  2755. minder.on('exportNodeData', function() {
  2756. parentFSM.jump('modal', 'export-text-modal');
  2757. var exportModal = $modal.open({
  2758. animation: true,
  2759. templateUrl: 'ui/dialog/imExportNode/imExportNode.tpl.html',
  2760. controller: 'imExportNode.ctrl',
  2761. size: 'md',
  2762. resolve: {
  2763. title: function() {
  2764. return '导出节点';
  2765. },
  2766. defaultValue: function() {
  2767. var selectedNode = minder.getSelectedNode(),
  2768. Node2Text = window.kityminder.data.getRegisterProtocol('text').Node2Text;
  2769. return Node2Text(selectedNode);
  2770. },
  2771. type: function() {
  2772. return 'export';
  2773. }
  2774. }
  2775. });
  2776. exportModal.result.then(function(result) {
  2777. parentFSM.jump('normal', 'export-text-finish');
  2778. editor.receiver.selectAll();
  2779. }, function() {
  2780. parentFSM.jump('normal', 'export-text-finish');
  2781. editor.receiver.selectAll();
  2782. });
  2783. });
  2784. });
  2785. return {};
  2786. }]);
  2787. /**
  2788. * @fileOverview
  2789. *
  2790. * 与后端交互的服务
  2791. *
  2792. * @author: zhangbobell
  2793. * @email : zhangbobell@163.com
  2794. *
  2795. * @copyright: Baidu FEX, 2015
  2796. */
  2797. angular.module('kityminderEditor')
  2798. .service('server', ['config', '$http', function(config, $http) {
  2799. return {
  2800. uploadImage: function(file) {
  2801. var url = config.get('imageUpload');
  2802. var fd = new FormData();
  2803. fd.append('upload_file', file);
  2804. return $http.post(url, fd, {
  2805. transformRequest: angular.identity,
  2806. headers: {'Content-Type': undefined}
  2807. });
  2808. }
  2809. }
  2810. }]);
  2811. angular.module('kityminderEditor')
  2812. .service('valueTransfer', function() {
  2813. return {};
  2814. });
  2815. angular.module('kityminderEditor')
  2816. .filter('commandState', function() {
  2817. return function(minder, command) {
  2818. return minder.queryCommandState(command);
  2819. }
  2820. })
  2821. .filter('commandValue', function() {
  2822. return function(minder, command) {
  2823. return minder.queryCommandValue(command);
  2824. }
  2825. });
  2826. angular.module('kityminderEditor')
  2827. .filter('lang', ['config', 'lang.zh-cn', function(config, lang) {
  2828. return function(text, block) {
  2829. var defaultLang = config.get('defaultLang');
  2830. if (lang[defaultLang] == undefined) {
  2831. return '未发现对应语言包,请检查 lang.xxx.service.js!';
  2832. } else {
  2833. var dict = lang[defaultLang];
  2834. block.split('/').forEach(function(ele, idx) {
  2835. dict = dict[ele];
  2836. });
  2837. return dict[text] || null;
  2838. }
  2839. };
  2840. }]);
  2841. angular.module('kityminderEditor')
  2842. .controller('hyperlink.ctrl', ["$scope", "$modalInstance", "link", function ($scope, $modalInstance, link) {
  2843. var urlRegex = '^(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$';
  2844. $scope.R_URL = new RegExp(urlRegex, 'i');
  2845. $scope.url = link.url || '';
  2846. $scope.title = link.title || '';
  2847. setTimeout(function() {
  2848. var $linkUrl = $('#link-url');
  2849. $linkUrl.focus();
  2850. $linkUrl[0].setSelectionRange(0, $scope.url.length);
  2851. }, 30);
  2852. $scope.shortCut = function(e) {
  2853. e.stopPropagation();
  2854. if (e.keyCode == 13) {
  2855. $scope.ok();
  2856. } else if (e.keyCode == 27) {
  2857. $scope.cancel();
  2858. }
  2859. };
  2860. $scope.ok = function () {
  2861. if($scope.R_URL.test($scope.url)) {
  2862. $modalInstance.close({
  2863. url: $scope.url,
  2864. title: $scope.title
  2865. });
  2866. } else {
  2867. $scope.urlPassed = false;
  2868. var $linkUrl = $('#link-url');
  2869. $linkUrl.focus();
  2870. $linkUrl[0].setSelectionRange(0, $scope.url.length);
  2871. }
  2872. editor.receiver.selectAll();
  2873. };
  2874. $scope.cancel = function () {
  2875. $modalInstance.dismiss('cancel');
  2876. editor.receiver.selectAll();
  2877. };
  2878. }]);
  2879. angular.module('kityminderEditor')
  2880. .controller('imExportNode.ctrl', ["$scope", "$modalInstance", "title", "defaultValue", "type", function ($scope, $modalInstance, title, defaultValue, type) {
  2881. $scope.title = title;
  2882. $scope.value = defaultValue;
  2883. $scope.type = type;
  2884. $scope.ok = function () {
  2885. if ($scope.value == '') {
  2886. return;
  2887. }
  2888. $modalInstance.close($scope.value);
  2889. editor.receiver.selectAll();
  2890. };
  2891. $scope.cancel = function () {
  2892. $modalInstance.dismiss('cancel');
  2893. editor.receiver.selectAll();
  2894. };
  2895. setTimeout(function() {
  2896. $('.single-input').focus();
  2897. $('.single-input')[0].setSelectionRange(0, defaultValue.length);
  2898. }, 30);
  2899. $scope.shortCut = function(e) {
  2900. e.stopPropagation();
  2901. //if (e.keyCode == 13 && e.shiftKey == false) {
  2902. // $scope.ok();
  2903. //}
  2904. if (e.keyCode == 27) {
  2905. $scope.cancel();
  2906. }
  2907. // tab 键屏蔽默认事件 和 backspace 键屏蔽默认事件
  2908. if (e.keyCode == 8 && type == 'export') {
  2909. e.preventDefault();
  2910. }
  2911. if (e.keyCode == 9) {
  2912. e.preventDefault();
  2913. var $textarea = e.target;
  2914. var pos = getCursortPosition($textarea);
  2915. var str = $textarea.value;
  2916. $textarea.value = str.substr(0, pos) + '\t' + str.substr(pos);
  2917. setCaretPosition($textarea, pos + 1);
  2918. }
  2919. };
  2920. /*
  2921. * 获取 textarea 的光标位置
  2922. * @Author: Naixor
  2923. * @date: 2015.09.23
  2924. * */
  2925. function getCursortPosition (ctrl) {
  2926. var CaretPos = 0; // IE Support
  2927. if (document.selection) {
  2928. ctrl.focus ();
  2929. var Sel = document.selection.createRange ();
  2930. Sel.moveStart ('character', -ctrl.value.length);
  2931. CaretPos = Sel.text.length;
  2932. }
  2933. // Firefox support
  2934. else if (ctrl.selectionStart || ctrl.selectionStart == '0') {
  2935. CaretPos = ctrl.selectionStart;
  2936. }
  2937. return (CaretPos);
  2938. }
  2939. /*
  2940. * 设置 textarea 的光标位置
  2941. * @Author: Naixor
  2942. * @date: 2015.09.23
  2943. * */
  2944. function setCaretPosition(ctrl, pos){
  2945. if(ctrl.setSelectionRange) {
  2946. ctrl.focus();
  2947. ctrl.setSelectionRange(pos,pos);
  2948. } else if (ctrl.createTextRange) {
  2949. var range = ctrl.createTextRange();
  2950. range.collapse(true);
  2951. range.moveEnd('character', pos);
  2952. range.moveStart('character', pos);
  2953. range.select();
  2954. }
  2955. }
  2956. }]);
  2957. angular.module('kityminderEditor')
  2958. .controller('image.ctrl', ['$http', '$scope', '$modalInstance', 'image', 'server', function($http, $scope, $modalInstance, image, server) {
  2959. $scope.data = {
  2960. list: [],
  2961. url: image.url || '',
  2962. title: image.title || '',
  2963. R_URL: /^https?\:\/\/\w+/
  2964. };
  2965. setTimeout(function() {
  2966. var $imageUrl = $('#image-url');
  2967. $imageUrl.focus();
  2968. $imageUrl[0].setSelectionRange(0, $scope.data.url.length);
  2969. }, 300);
  2970. // 搜索图片按钮点击事件
  2971. $scope.searchImage = function() {
  2972. $scope.list = [];
  2973. getImageData()
  2974. .success(function(json) {
  2975. if(json && json.data) {
  2976. for(var i = 0; i < json.data.length; i++) {
  2977. if(json.data[i].objURL) {
  2978. $scope.list.push({
  2979. title: json.data[i].fromPageTitleEnc,
  2980. src: json.data[i].middleURL,
  2981. url: json.data[i].middleURL
  2982. });
  2983. }
  2984. }
  2985. }
  2986. })
  2987. .error(function() {
  2988. });
  2989. };
  2990. // 选择图片的鼠标点击事件
  2991. $scope.selectImage = function($event) {
  2992. var targetItem = $('#img-item'+ (this.$index));
  2993. var targetImg = $('#img-'+ (this.$index));
  2994. targetItem.siblings('.selected').removeClass('selected');
  2995. targetItem.addClass('selected');
  2996. $scope.data.url = targetImg.attr('src');
  2997. $scope.data.title = targetImg.attr('alt');
  2998. };
  2999. // 自动上传图片,后端需要直接返回图片 URL
  3000. $scope.uploadImage = function() {
  3001. var fileInput = $('#upload-image');
  3002. if (!fileInput.val()) {
  3003. return;
  3004. }
  3005. if (/^.*\.(jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG)$/.test(fileInput.val())) {
  3006. var file = fileInput[0].files[0];
  3007. return server.uploadImage(file).then(function (json) {
  3008. var resp = json.data;
  3009. if (resp.errno === 0) {
  3010. $scope.data.url = resp.data.url;
  3011. }
  3012. });
  3013. } else {
  3014. alert("后缀只能是 jpg、gif 及 png");
  3015. }
  3016. };
  3017. $scope.shortCut = function(e) {
  3018. e.stopPropagation();
  3019. if (e.keyCode == 13) {
  3020. $scope.ok();
  3021. } else if (e.keyCode == 27) {
  3022. $scope.cancel();
  3023. }
  3024. };
  3025. $scope.ok = function () {
  3026. if($scope.data.R_URL.test($scope.data.url)) {
  3027. $modalInstance.close({
  3028. url: $scope.data.url,
  3029. title: $scope.data.title
  3030. });
  3031. } else {
  3032. $scope.urlPassed = false;
  3033. var $imageUrl = $('#image-url');
  3034. if ($imageUrl) {
  3035. $imageUrl.focus();
  3036. $imageUrl[0].setSelectionRange(0, $scope.data.url.length);
  3037. }
  3038. }
  3039. editor.receiver.selectAll();
  3040. };
  3041. $scope.cancel = function () {
  3042. $modalInstance.dismiss('cancel');
  3043. editor.receiver.selectAll();
  3044. };
  3045. function getImageData() {
  3046. var key = $scope.data.searchKeyword2;
  3047. var currentTime = new Date();
  3048. var url = 'http://image.baidu.com/search/acjson?tn=resultjson_com&ipn=rj&ct=201326592&fp=result&queryWord='+ key +'&cl=2&lm=-1&ie=utf-8&oe=utf-8&st=-1&ic=0&word='+ key +'&face=0&istype=2&nc=1&pn=60&rn=60&gsm=3c&'+ currentTime.getTime() +'=&callback=JSON_CALLBACK';
  3049. return $http.jsonp(url);
  3050. }
  3051. }]);
  3052. angular.module('kityminderEditor')
  3053. .directive('appendNode', ['commandBinder', function(commandBinder) {
  3054. return {
  3055. restrict: 'E',
  3056. templateUrl: 'ui/directive/appendNode/appendNode.html',
  3057. scope: {
  3058. minder: '='
  3059. },
  3060. replace: true,
  3061. link: function($scope) {
  3062. var minder = $scope.minder;
  3063. commandBinder.bind(minder, 'appendchildnode', $scope)
  3064. $scope.execCommand = function(command) {
  3065. minder.execCommand(command, '分支主题');
  3066. editText();
  3067. };
  3068. function editText() {
  3069. var receiverElement = editor.receiver.element;
  3070. var fsm = editor.fsm;
  3071. var receiver = editor.receiver;
  3072. receiverElement.innerText = minder.queryCommandValue('text');
  3073. fsm.jump('input', 'input-request');
  3074. receiver.selectAll();
  3075. }
  3076. }
  3077. }
  3078. }]);
  3079. angular.module('kityminderEditor')
  3080. .directive('arrange', ['commandBinder', function(commandBinder) {
  3081. return {
  3082. restrict: 'E',
  3083. templateUrl: 'ui/directive/arrange/arrange.html',
  3084. scope: {
  3085. minder: '='
  3086. },
  3087. replace: true,
  3088. link: function($scope) {
  3089. var minder = $scope.minder;
  3090. //commandBinder.bind(minder, 'priority', $scope);
  3091. }
  3092. }
  3093. }]);
  3094. angular.module('kityminderEditor')
  3095. .directive('colorPanel', function() {
  3096. return {
  3097. restrict: 'E',
  3098. templateUrl: 'ui/directive/colorPanel/colorPanel.html',
  3099. scope: {
  3100. minder: '='
  3101. },
  3102. replace: true,
  3103. link: function(scope) {
  3104. var minder = scope.minder;
  3105. var currentTheme = minder.getThemeItems();
  3106. scope.$on('colorPicked', function(event, color) {
  3107. event.stopPropagation();
  3108. scope.bgColor = color;
  3109. minder.execCommand('background', color);
  3110. });
  3111. scope.setDefaultBg = function() {
  3112. var currentNode = minder.getSelectedNode();
  3113. var bgColor = minder.getNodeStyle(currentNode, 'background');
  3114. // 有可能是 kity 的颜色类
  3115. return typeof bgColor === 'object' ? bgColor.toHEX() : bgColor;
  3116. };
  3117. scope.bgColor = scope.setDefaultBg() || '#fff';
  3118. }
  3119. }
  3120. });
  3121. angular.module('kityminderEditor')
  3122. .directive('expandLevel', function() {
  3123. return {
  3124. restrict: 'E',
  3125. templateUrl: 'ui/directive/expandLevel/expandLevel.html',
  3126. scope: {
  3127. minder: '='
  3128. },
  3129. replace: true,
  3130. link: function($scope) {
  3131. $scope.levels = [1, 2, 3, 4, 5, 6];
  3132. }
  3133. }
  3134. });
  3135. angular.module('kityminderEditor')
  3136. .directive('fontOperator', function() {
  3137. return {
  3138. restrict: 'E',
  3139. templateUrl: 'ui/directive/fontOperator/fontOperator.html',
  3140. scope: {
  3141. minder: '='
  3142. },
  3143. replace: true,
  3144. link: function(scope) {
  3145. var minder = scope.minder;
  3146. var currentTheme = minder.getThemeItems();
  3147. scope.fontSizeList = [10, 12, 16, 18, 24, 32, 48];
  3148. scope.fontFamilyList = [{
  3149. name: '宋体',
  3150. val: '宋体,SimSun'
  3151. }, {
  3152. name: '微软雅黑',
  3153. val: '微软雅黑,Microsoft YaHei'
  3154. }, {
  3155. name: '楷体',
  3156. val: '楷体,楷体_GB2312,SimKai'
  3157. }, {
  3158. name: '黑体',
  3159. val: '黑体, SimHei'
  3160. }, {
  3161. name: '隶书',
  3162. val: '隶书, SimLi'
  3163. }, {
  3164. name: 'Andale Mono',
  3165. val: 'andale mono'
  3166. }, {
  3167. name: 'Arial',
  3168. val: 'arial,helvetica,sans-serif'
  3169. }, {
  3170. name: 'arialBlack',
  3171. val: 'arial black,avant garde'
  3172. }, {
  3173. name: 'Comic Sans Ms',
  3174. val: 'comic sans ms'
  3175. }, {
  3176. name: 'Impact',
  3177. val: 'impact,chicago'
  3178. }, {
  3179. name: 'Times New Roman',
  3180. val: 'times new roman'
  3181. }, {
  3182. name: 'Sans-Serif',
  3183. val: 'sans-serif'
  3184. }];
  3185. scope.$on('colorPicked', function(event, color) {
  3186. event.stopPropagation();
  3187. scope.foreColor = color;
  3188. minder.execCommand('forecolor', color);
  3189. });
  3190. scope.setDefaultColor = function() {
  3191. var currentNode = minder.getSelectedNode();
  3192. var fontColor = minder.getNodeStyle(currentNode, 'color');
  3193. // 有可能是 kity 的颜色类
  3194. return typeof fontColor === 'object' ? fontColor.toHEX() : fontColor;
  3195. };
  3196. scope.foreColor = scope.setDefaultColor() || '#000';
  3197. scope.getFontfamilyName = function(val) {
  3198. var fontName = '';
  3199. scope.fontFamilyList.forEach(function(ele, idx, arr) {
  3200. if (ele.val === val) {
  3201. fontName = ele.name;
  3202. return '';
  3203. }
  3204. });
  3205. return fontName;
  3206. }
  3207. }
  3208. }
  3209. });
  3210. angular.module('kityminderEditor')
  3211. .directive('hyperLink', ['$modal', function($modal) {
  3212. return {
  3213. restrict: 'E',
  3214. templateUrl: 'ui/directive/hyperLink/hyperLink.html',
  3215. scope: {
  3216. minder: '='
  3217. },
  3218. replace: true,
  3219. link: function($scope) {
  3220. var minder = $scope.minder;
  3221. $scope.addHyperlink = function() {
  3222. var link = minder.queryCommandValue('HyperLink');
  3223. var hyperlinkModal = $modal.open({
  3224. animation: true,
  3225. templateUrl: 'ui/dialog/hyperlink/hyperlink.tpl.html',
  3226. controller: 'hyperlink.ctrl',
  3227. size: 'md',
  3228. resolve: {
  3229. link: function() {
  3230. return link;
  3231. }
  3232. }
  3233. });
  3234. hyperlinkModal.result.then(function(result) {
  3235. minder.execCommand('HyperLink', result.url, result.title || '');
  3236. });
  3237. }
  3238. }
  3239. }
  3240. }]);
  3241. angular.module('kityminderEditor')
  3242. .directive('imageBtn', ['$modal', function($modal) {
  3243. return {
  3244. restrict: 'E',
  3245. templateUrl: 'ui/directive/imageBtn/imageBtn.html',
  3246. scope: {
  3247. minder: '='
  3248. },
  3249. replace: true,
  3250. link: function($scope) {
  3251. var minder = $scope.minder;
  3252. $scope.addImage = function() {
  3253. var image = minder.queryCommandValue('image');
  3254. var imageModal = $modal.open({
  3255. animation: true,
  3256. templateUrl: 'ui/dialog/image/image.tpl.html',
  3257. controller: 'image.ctrl',
  3258. size: 'md',
  3259. resolve: {
  3260. image: function() {
  3261. return image;
  3262. }
  3263. }
  3264. });
  3265. imageModal.result.then(function(result) {
  3266. minder.execCommand('image', result.url, result.title || '');
  3267. });
  3268. }
  3269. }
  3270. }
  3271. }]);
  3272. angular.module('kityminderEditor')
  3273. .directive('kityminderEditor', ['config', 'minder.service', 'revokeDialog', function(config, minderService, revokeDialog) {
  3274. return {
  3275. restrict: 'EA',
  3276. templateUrl: 'ui/directive/kityminderEditor/kityminderEditor.html',
  3277. replace: true,
  3278. scope: {
  3279. onInit: '&'
  3280. },
  3281. link: function(scope, element, attributes) {
  3282. var $minderEditor = element.children('.minder-editor')[0];
  3283. function onInit(editor, minder) {
  3284. scope.onInit({
  3285. editor: editor,
  3286. minder: minder
  3287. });
  3288. minderService.executeCallback();
  3289. }
  3290. if (typeof(seajs) != 'undefined') {
  3291. /* global seajs */
  3292. seajs.config({
  3293. base: './src'
  3294. });
  3295. define('demo', function(require) {
  3296. var Editor = require('editor');
  3297. var editor = window.editor = new Editor($minderEditor);
  3298. if (window.localStorage.__dev_minder_content) {
  3299. editor.minder.importJson(JSON.parse(window.localStorage.__dev_minder_content));
  3300. }
  3301. editor.minder.on('contentchange', function() {
  3302. window.localStorage.__dev_minder_content = JSON.stringify(editor.minder.exportJson());
  3303. });
  3304. window.minder = window.km = editor.minder;
  3305. scope.editor = editor;
  3306. scope.minder = minder;
  3307. scope.config = config.get();
  3308. //scope.minder.setDefaultOptions(scope.config);
  3309. scope.$apply();
  3310. onInit(editor, minder);
  3311. });
  3312. seajs.use('demo');
  3313. } else if (window.kityminder && window.kityminder.Editor) {
  3314. var editor = new kityminder.Editor($minderEditor);
  3315. window.editor = scope.editor = editor;
  3316. window.minder = scope.minder = editor.minder;
  3317. scope.config = config.get();
  3318. //scope.minder.setDefaultOptions(config.getConfig());
  3319. onInit(editor, editor.minder);
  3320. }
  3321. }
  3322. }
  3323. }]);
  3324. angular.module('kityminderEditor')
  3325. .directive('kityminderViewer', ['config', 'minder.service', function(config, minderService) {
  3326. return {
  3327. restrict: 'EA',
  3328. templateUrl: 'ui/directive/kityminderViewer/kityminderViewer.html',
  3329. replace: true,
  3330. scope: {
  3331. onInit: '&'
  3332. },
  3333. link: function(scope, element, attributes) {
  3334. var $minderEditor = element.children('.minder-viewer')[0];
  3335. function onInit(editor, minder) {
  3336. scope.onInit({
  3337. editor: editor,
  3338. minder: minder
  3339. });
  3340. minderService.executeCallback();
  3341. }
  3342. if (window.kityminder && window.kityminder.Editor) {
  3343. var editor = new kityminder.Editor($minderEditor);
  3344. window.editor = scope.editor = editor;
  3345. window.minder = scope.minder = editor.minder;
  3346. onInit(editor, editor.minder);
  3347. }
  3348. }
  3349. }
  3350. }]);
  3351. angular.module('kityminderEditor')
  3352. .directive('layout', function() {
  3353. return {
  3354. restrict: 'E',
  3355. templateUrl: 'ui/directive/layout/layout.html',
  3356. scope: {
  3357. minder: '='
  3358. },
  3359. replace: true,
  3360. link: function(scope) {
  3361. }
  3362. }
  3363. });
  3364. /**
  3365. * @fileOverview
  3366. *
  3367. * 左下角的导航器
  3368. *
  3369. * @author: zhangbobell
  3370. * @email : zhangbobell@163.com
  3371. *
  3372. * @copyright: Baidu FEX, 2015 */
  3373. angular.module('kityminderEditor')
  3374. .directive('navigator', ['memory', 'config', function(memory, config) {
  3375. return {
  3376. restrict: 'A',
  3377. templateUrl: 'ui/directive/navigator/navigator.html',
  3378. scope: {
  3379. minder: '='
  3380. },
  3381. link: function(scope) {
  3382. minder.setDefaultOptions({zoom: config.get('zoom')});
  3383. scope.isNavOpen = !memory.get('navigator-hidden');
  3384. scope.getZoomRadio = function(value) {
  3385. var zoomStack = minder.getOption('zoom');
  3386. var minValue = zoomStack[0];
  3387. var maxValue = zoomStack[zoomStack.length - 1];
  3388. var valueRange = maxValue - minValue;
  3389. return (1 - (value - minValue) / valueRange);
  3390. };
  3391. scope.getHeight = function(value) {
  3392. var totalHeight = $('.zoom-pan').height();
  3393. return scope.getZoomRadio(value) * totalHeight;
  3394. };
  3395. // 初始的缩放倍数
  3396. scope.zoom = 100;
  3397. // 发生缩放事件时
  3398. minder.on('zoom', function(e) {
  3399. scope.zoom = e.zoom;
  3400. });
  3401. scope.toggleNavOpen = function() {
  3402. scope.isNavOpen = !scope.isNavOpen;
  3403. memory.set('navigator-hidden', !scope.isNavOpen);
  3404. if (scope.isNavOpen) {
  3405. bind();
  3406. updateContentView();
  3407. updateVisibleView();
  3408. } else{
  3409. unbind();
  3410. }
  3411. };
  3412. setTimeout(function() {
  3413. if (scope.isNavOpen) {
  3414. bind();
  3415. updateContentView();
  3416. updateVisibleView();
  3417. } else{
  3418. unbind();
  3419. }
  3420. }, 0);
  3421. function bind() {
  3422. minder.on('layout layoutallfinish', updateContentView);
  3423. minder.on('viewchange', updateVisibleView);
  3424. }
  3425. function unbind() {
  3426. minder.off('layout layoutallfinish', updateContentView);
  3427. minder.off('viewchange', updateVisibleView);
  3428. }
  3429. /** 以下部分是缩略图导航器 *
  3430. * */
  3431. var $previewNavigator = $('.nav-previewer');
  3432. // 画布,渲染缩略图
  3433. var paper = new kity.Paper($previewNavigator[0]);
  3434. // 用两个路径来挥之节点和连线的缩略图
  3435. var nodeThumb = paper.put(new kity.Path());
  3436. var connectionThumb = paper.put(new kity.Path());
  3437. // 表示可视区域的矩形
  3438. var visibleRect = paper.put(new kity.Rect(100, 100).stroke('red', '1%'));
  3439. var contentView = new kity.Box(), visibleView = new kity.Box();
  3440. /**
  3441. * 增加一个对天盘图情况缩略图的处理,
  3442. * @Editor: Naixor line 104~129
  3443. * @Date: 2015.11.3
  3444. */
  3445. var pathHandler = getPathHandler(minder.getTheme());
  3446. // 主题切换事件
  3447. minder.on('themechange', function(e) {
  3448. pathHandler = getPathHandler(e.theme);
  3449. });
  3450. function getPathHandler(theme) {
  3451. switch (theme) {
  3452. case "tianpan":
  3453. case "tianpan-compact":
  3454. return function(nodePathData, x, y, width, height) {
  3455. var r = width >> 1;
  3456. nodePathData.push('M', x, y + r,
  3457. 'a', r, r, 0, 1, 1, 0, 0.01,
  3458. 'z');
  3459. }
  3460. default: {
  3461. return function(nodePathData, x, y, width, height) {
  3462. nodePathData.push('M', x, y,
  3463. 'h', width, 'v', height,
  3464. 'h', -width, 'z');
  3465. }
  3466. }
  3467. }
  3468. }
  3469. navigate();
  3470. function navigate() {
  3471. function moveView(center, duration) {
  3472. var box = visibleView;
  3473. center.x = -center.x;
  3474. center.y = -center.y;
  3475. var viewMatrix = minder.getPaper().getViewPortMatrix();
  3476. box = viewMatrix.transformBox(box);
  3477. var targetPosition = center.offset(box.width / 2, box.height / 2);
  3478. minder.getViewDragger().moveTo(targetPosition, duration);
  3479. }
  3480. var dragging = false;
  3481. paper.on('mousedown', function(e) {
  3482. dragging = true;
  3483. moveView(e.getPosition('top'), 200);
  3484. $previewNavigator.addClass('grab');
  3485. });
  3486. paper.on('mousemove', function(e) {
  3487. if (dragging) {
  3488. moveView(e.getPosition('top'));
  3489. }
  3490. });
  3491. $(window).on('mouseup', function() {
  3492. dragging = false;
  3493. $previewNavigator.removeClass('grab');
  3494. });
  3495. }
  3496. function updateContentView() {
  3497. var view = minder.getRenderContainer().getBoundaryBox();
  3498. contentView = view;
  3499. var padding = 30;
  3500. paper.setViewBox(
  3501. view.x - padding - 0.5,
  3502. view.y - padding - 0.5,
  3503. view.width + padding * 2 + 1,
  3504. view.height + padding * 2 + 1);
  3505. var nodePathData = [];
  3506. var connectionThumbData = [];
  3507. minder.getRoot().traverse(function(node) {
  3508. var box = node.getLayoutBox();
  3509. pathHandler(nodePathData, box.x, box.y, box.width, box.height);
  3510. if (node.getConnection() && node.parent && node.parent.isExpanded()) {
  3511. connectionThumbData.push(node.getConnection().getPathData());
  3512. }
  3513. });
  3514. paper.setStyle('background', minder.getStyle('background'));
  3515. if (nodePathData.length) {
  3516. nodeThumb
  3517. .fill(minder.getStyle('root-background'))
  3518. .setPathData(nodePathData);
  3519. } else {
  3520. nodeThumb.setPathData(null);
  3521. }
  3522. if (connectionThumbData.length) {
  3523. connectionThumb
  3524. .stroke(minder.getStyle('connect-color'), '0.5%')
  3525. .setPathData(connectionThumbData);
  3526. } else {
  3527. connectionThumb.setPathData(null);
  3528. }
  3529. updateVisibleView();
  3530. }
  3531. function updateVisibleView() {
  3532. visibleView = minder.getViewDragger().getView();
  3533. visibleRect.setBox(visibleView.intersect(contentView));
  3534. }
  3535. }
  3536. }
  3537. }]);
  3538. angular.module('kityminderEditor')
  3539. .directive('noteBtn', ['valueTransfer', function(valueTransfer) {
  3540. return {
  3541. restrict: 'E',
  3542. templateUrl: 'ui/directive/noteBtn/noteBtn.html',
  3543. scope: {
  3544. minder: '='
  3545. },
  3546. replace: true,
  3547. link: function($scope) {
  3548. var minder = $scope.minder;
  3549. $scope.addNote =function() {
  3550. valueTransfer.noteEditorOpen = true;
  3551. };
  3552. }
  3553. }
  3554. }]);
  3555. angular.module('kityminderEditor')
  3556. .directive('noteEditor', ['valueTransfer', function(valueTransfer) {
  3557. return {
  3558. restrict: 'A',
  3559. templateUrl: 'ui/directive/noteEditor/noteEditor.html',
  3560. scope: {
  3561. minder: '='
  3562. },
  3563. replace: true,
  3564. controller: ["$scope", function($scope) {
  3565. var minder = $scope.minder;
  3566. var isInteracting = false;
  3567. var cmEditor;
  3568. $scope.codemirrorLoaded = function(_editor) {
  3569. cmEditor = $scope.cmEditor = _editor;
  3570. _editor.setSize('100%', '100%');
  3571. };
  3572. function updateNote() {
  3573. var enabled = $scope.noteEnabled = minder.queryCommandState('note') != -1;
  3574. var noteValue = minder.queryCommandValue('note') || '';
  3575. if (enabled) {
  3576. $scope.noteContent = noteValue;
  3577. }
  3578. isInteracting = true;
  3579. $scope.$apply();
  3580. isInteracting = false;
  3581. }
  3582. $scope.$watch('noteContent', function(content) {
  3583. var enabled = minder.queryCommandState('note') != -1;
  3584. if (content && enabled && !isInteracting) {
  3585. minder.execCommand('note', content);
  3586. }
  3587. setTimeout(function() {
  3588. cmEditor.refresh();
  3589. });
  3590. });
  3591. var noteEditorOpen = function() {
  3592. return valueTransfer.noteEditorOpen;
  3593. };
  3594. // 监听面板状态变量的改变
  3595. $scope.$watch(noteEditorOpen, function(newVal, oldVal) {
  3596. if (newVal) {
  3597. setTimeout(function() {
  3598. cmEditor.refresh();
  3599. cmEditor.focus();
  3600. });
  3601. }
  3602. $scope.noteEditorOpen = valueTransfer.noteEditorOpen;
  3603. }, true);
  3604. $scope.closeNoteEditor = function() {
  3605. valueTransfer.noteEditorOpen = false;
  3606. editor.receiver.selectAll();
  3607. };
  3608. minder.on('interactchange', updateNote);
  3609. }]
  3610. }
  3611. }]);
  3612. // TODO: 使用一个 div 容器作为 previewer,而不是两个
  3613. angular.module('kityminderEditor')
  3614. .directive('notePreviewer', ['$sce', 'valueTransfer', function($sce, valueTransfer) {
  3615. return {
  3616. restrict: 'A',
  3617. templateUrl: 'ui/directive/notePreviewer/notePreviewer.html',
  3618. link: function(scope, element) {
  3619. var minder = scope.minder;
  3620. var $container = element.parent();
  3621. var $previewer = element.children();
  3622. scope.showNotePreviewer = false;
  3623. marked.setOptions({
  3624. gfm: true,
  3625. tables: true,
  3626. breaks: true,
  3627. pedantic: false,
  3628. sanitize: true,
  3629. smartLists: true,
  3630. smartypants: false
  3631. });
  3632. var previewTimer;
  3633. minder.on('shownoterequest', function(e) {
  3634. previewTimer = setTimeout(function() {
  3635. preview(e.node, e.keyword);
  3636. }, 300);
  3637. });
  3638. minder.on('hidenoterequest', function() {
  3639. clearTimeout(previewTimer);
  3640. scope.showNotePreviewer = false;
  3641. //scope.$apply();
  3642. });
  3643. var previewLive = false;
  3644. $(document).on('mousedown mousewheel DOMMouseScroll', function() {
  3645. if (!previewLive) return;
  3646. scope.showNotePreviewer = false;
  3647. scope.$apply();
  3648. });
  3649. element.on('mousedown mousewheel DOMMouseScroll', function(e) {
  3650. e.stopPropagation();
  3651. });
  3652. function preview(node, keyword) {
  3653. var icon = node.getRenderer('NoteIconRenderer').getRenderShape();
  3654. var b = icon.getRenderBox('screen');
  3655. var note = node.getData('note');
  3656. $previewer[0].scrollTop = 0;
  3657. var html = marked(note);
  3658. if (keyword) {
  3659. html = html.replace(new RegExp('(' + keyword + ')', 'ig'), '<span class="highlight">$1</span>');
  3660. }
  3661. scope.noteContent = $sce.trustAsHtml(html);
  3662. scope.$apply(); // 让浏览器重新渲染以获取 previewer 提示框的尺寸
  3663. var cw = $($container[0]).width();
  3664. var ch = $($container[0]).height();
  3665. var pw = $($previewer).outerWidth();
  3666. var ph = $($previewer).outerHeight();
  3667. var x = b.cx - pw / 2 - $container[0].offsetLeft;
  3668. var y = b.bottom + 10 - $container[0].offsetTop;
  3669. if (x < 0) x = 10;
  3670. if (x + pw > cw) x = b.left - pw - 10 - $container[0].offsetLeft;
  3671. if (y + ph > ch) y = b.top - ph - 10 - $container[0].offsetTop;
  3672. scope.previewerStyle = {
  3673. 'left': Math.round(x) + 'px',
  3674. 'top': Math.round(y) + 'px'
  3675. };
  3676. scope.showNotePreviewer = true;
  3677. var view = $previewer[0].querySelector('.highlight');
  3678. if (view) {
  3679. view.scrollIntoView();
  3680. }
  3681. previewLive = true;
  3682. scope.$apply();
  3683. }
  3684. }
  3685. }
  3686. }]);
  3687. angular.module('kityminderEditor')
  3688. .directive('operation', function() {
  3689. return {
  3690. restrict: 'E',
  3691. templateUrl: 'ui/directive/operation/operation.html',
  3692. scope: {
  3693. minder: '='
  3694. },
  3695. replace: true,
  3696. link: function($scope) {
  3697. $scope.editNode = function() {
  3698. var receiverElement = editor.receiver.element;
  3699. var fsm = editor.fsm;
  3700. var receiver = editor.receiver;
  3701. receiverElement.innerText = minder.queryCommandValue('text');
  3702. fsm.jump('input', 'input-request');
  3703. receiver.selectAll();
  3704. }
  3705. }
  3706. }
  3707. });
  3708. angular.module('kityminderEditor')
  3709. .directive('priorityEditor', ['commandBinder', function(commandBinder) {
  3710. return {
  3711. restrict: 'E',
  3712. templateUrl: 'ui/directive/priorityEditor/priorityEditor.html',
  3713. scope: {
  3714. minder: '='
  3715. },
  3716. replace: true,
  3717. link: function($scope) {
  3718. var minder = $scope.minder;
  3719. var priorities = [];
  3720. for (var i = 0; i < 10; i++) {
  3721. priorities.push(i);
  3722. }
  3723. commandBinder.bind(minder, 'priority', $scope);
  3724. $scope.priorities = priorities;
  3725. $scope.getPriorityTitle = function(p) {
  3726. switch(p) {
  3727. case 0: return '移除优先级';
  3728. default: return '优先级' + p;
  3729. }
  3730. }
  3731. }
  3732. }
  3733. }]);
  3734. angular.module('kityminderEditor')
  3735. .directive('progressEditor', ['commandBinder', function(commandBinder) {
  3736. return {
  3737. restrict: 'E',
  3738. templateUrl: 'ui/directive/progressEditor/progressEditor.html',
  3739. scope: {
  3740. minder: '='
  3741. },
  3742. replace: true,
  3743. link: function($scope) {
  3744. var minder = $scope.minder;
  3745. var progresses = [];
  3746. for (var i = 0; i < 10; i++) {
  3747. progresses.push(i);
  3748. }
  3749. commandBinder.bind(minder, 'progress', $scope);
  3750. $scope.progresses = progresses;
  3751. $scope.getProgressTitle = function(p) {
  3752. switch(p) {
  3753. case 0: return '移除进度';
  3754. case 1: return '未开始';
  3755. case 9: return '全部完成';
  3756. default: return '完成' + (p - 1) + '/8';
  3757. }
  3758. }
  3759. }
  3760. }
  3761. }])
  3762. angular.module('kityminderEditor')
  3763. .directive('resourceEditor', function () {
  3764. return {
  3765. restrict: 'E',
  3766. templateUrl: 'ui/directive/resourceEditor/resourceEditor.html',
  3767. scope: {
  3768. minder: '='
  3769. },
  3770. replace: true,
  3771. controller: ["$scope", function ($scope) {
  3772. var minder = $scope.minder;
  3773. var isInteracting = false;
  3774. minder.on('interactchange', function () {
  3775. var enabled = $scope.enabled = minder.queryCommandState('resource') != -1;
  3776. var selected = enabled ? minder.queryCommandValue('resource') : [];
  3777. var used = minder.getUsedResource().map(function (resourceName) {
  3778. return {
  3779. name: resourceName,
  3780. selected: selected.indexOf(resourceName) > -1
  3781. }
  3782. });
  3783. $scope.used = used;
  3784. isInteracting = true;
  3785. $scope.$apply();
  3786. isInteracting = false;
  3787. });
  3788. $scope.$watch('used', function (used) {
  3789. if (minder.queryCommandState('resource') != -1 && used) {
  3790. var resource = used.filter(function (resource) {
  3791. return resource.selected;
  3792. }).map(function (resource) {
  3793. return resource.name;
  3794. });
  3795. // 由于 interactchange 带来的改变则不用执行 resource 命令
  3796. if (isInteracting) {
  3797. return;
  3798. }
  3799. minder.execCommand('resource', resource);
  3800. }
  3801. }, true);
  3802. $scope.resourceColor = function (resource) {
  3803. return minder.getResourceColor(resource).toHEX();
  3804. };
  3805. $scope.addResource = function (resourceName) {
  3806. var origin = minder.queryCommandValue('resource');
  3807. if (!resourceName || !/\S/.test(resourceName)) return;
  3808. if (origin.indexOf(resourceName) == -1) {
  3809. $scope.used.push({
  3810. name: resourceName,
  3811. selected: true
  3812. });
  3813. }
  3814. $scope.newResourceName = null;
  3815. };
  3816. }]
  3817. };
  3818. })
  3819. .directive('clickAnywhereButHere', ['$document', function ($document) {
  3820. return {
  3821. link: function(scope, element, attrs) {
  3822. var onClick = function (event) {
  3823. var isChild = $('#resource-dropdown').has(event.target).length > 0;
  3824. var isSelf = $('#resource-dropdown') == event.target;
  3825. var isInside = isChild || isSelf;
  3826. if (!isInside) {
  3827. scope.$apply(attrs.clickAnywhereButHere)
  3828. }
  3829. };
  3830. scope.$watch(attrs.isActive, function(newValue, oldValue) {
  3831. if (newValue !== oldValue && newValue == true) {
  3832. $document.bind('click', onClick);
  3833. }
  3834. else if (newValue !== oldValue && newValue == false) {
  3835. $document.unbind('click', onClick);
  3836. }
  3837. });
  3838. }
  3839. };
  3840. }]);
  3841. angular.module('kityminderEditor')
  3842. .directive('searchBox', function() {
  3843. return {
  3844. restrict: 'A',
  3845. templateUrl: 'ui/directive/searchBox/searchBox.html',
  3846. scope: {
  3847. minder: '='
  3848. },
  3849. replace: true,
  3850. controller: ["$scope", function ($scope) {
  3851. var minder = $scope.minder;
  3852. var editor = window.editor;
  3853. $scope.handleKeyDown = handleKeyDown;
  3854. $scope.doSearch = doSearch;
  3855. $scope.exitSearch = exitSearch;
  3856. $scope.showTip = false;
  3857. $scope.showSearch = false;
  3858. // 处理输入框按键事件
  3859. function handleKeyDown(e) {
  3860. if (e.keyCode == 13) {
  3861. var direction = e.shiftKey ? 'prev' : 'next';
  3862. doSearch($scope.keyword, direction);
  3863. }
  3864. if (e.keyCode == 27) {
  3865. exitSearch();
  3866. }
  3867. }
  3868. function exitSearch() {
  3869. $('#search-input').blur();
  3870. $scope.showSearch = false;
  3871. minder.fire('hidenoterequest');
  3872. editor.receiver.selectAll();
  3873. }
  3874. function enterSearch() {
  3875. $scope.showSearch = true;
  3876. setTimeout(function() {
  3877. $('#search-input').focus();
  3878. }, 10);
  3879. if ($scope.keyword) {
  3880. $('#search-input')[0].setSelectionRange(0, $scope.keyword.length);
  3881. }
  3882. }
  3883. $('body').on('keydown', function(e) {
  3884. if (e.keyCode == 70 && (e.ctrlKey || e.metaKey) && !e.shiftKey) {
  3885. enterSearch();
  3886. $scope.$apply();
  3887. e.preventDefault();
  3888. }
  3889. });
  3890. minder.on('searchNode', function() {
  3891. enterSearch();
  3892. });
  3893. var nodeSequence = [];
  3894. var searchSequence = [];
  3895. minder.on('contentchange', makeNodeSequence);
  3896. makeNodeSequence();
  3897. function makeNodeSequence() {
  3898. nodeSequence = [];
  3899. minder.getRoot().traverse(function(node) {
  3900. nodeSequence.push(node);
  3901. });
  3902. }
  3903. function makeSearchSequence(keyword) {
  3904. searchSequence = [];
  3905. for (var i = 0; i < nodeSequence.length; i++) {
  3906. var node = nodeSequence[i];
  3907. var text = node.getText().toLowerCase();
  3908. if (text.indexOf(keyword) != -1) {
  3909. searchSequence.push({node:node});
  3910. }
  3911. var note = node.getData('note');
  3912. if (note && note.toLowerCase().indexOf(keyword) != -1) {
  3913. searchSequence.push({node: node, keyword: keyword});
  3914. }
  3915. }
  3916. }
  3917. function doSearch(keyword, direction) {
  3918. $scope.showTip = false;
  3919. minder.fire('hidenoterequest');
  3920. if (!keyword || !/\S/.exec(keyword)) {
  3921. $('#search-input').focus();
  3922. return;
  3923. }
  3924. // 当搜索不到节点时候默认的选项
  3925. $scope.showTip = true;
  3926. $scope.curIndex = 0;
  3927. $scope.resultNum = 0;
  3928. keyword = keyword.toLowerCase();
  3929. var newSearch = doSearch.lastKeyword != keyword;
  3930. doSearch.lastKeyword = keyword;
  3931. if (newSearch) {
  3932. makeSearchSequence(keyword);
  3933. }
  3934. $scope.resultNum = searchSequence.length;
  3935. if (searchSequence.length) {
  3936. var curIndex = newSearch ? 0 : (direction === 'next' ? doSearch.lastIndex + 1 : doSearch.lastIndex - 1) || 0;
  3937. curIndex = (searchSequence.length + curIndex) % searchSequence.length;
  3938. setSearchResult(searchSequence[curIndex].node, searchSequence[curIndex].keyword);
  3939. doSearch.lastIndex = curIndex;
  3940. $scope.curIndex = curIndex + 1;
  3941. function setSearchResult(node, previewKeyword) {
  3942. minder.execCommand('camera', node, 50);
  3943. setTimeout(function () {
  3944. minder.select(node, true);
  3945. if (!node.isExpanded()) minder.execCommand('expand', true);
  3946. if (previewKeyword) {
  3947. minder.fire('shownoterequest', {node: node, keyword: previewKeyword});
  3948. }
  3949. }, 60);
  3950. }
  3951. }
  3952. }
  3953. }]
  3954. }
  3955. });
  3956. angular.module('kityminderEditor')
  3957. .directive('searchBtn', function() {
  3958. return {
  3959. restrict: 'E',
  3960. templateUrl: 'ui/directive/searchBtn/searchBtn.html',
  3961. scope: {
  3962. minder: '='
  3963. },
  3964. replace: true,
  3965. link: function (scope) {
  3966. scope.enterSearch = enterSearch;
  3967. function enterSearch() {
  3968. minder.fire('searchNode');
  3969. }
  3970. }
  3971. }
  3972. });
  3973. angular.module('kityminderEditor')
  3974. .directive('selectAll', function() {
  3975. return {
  3976. restrict: 'E',
  3977. templateUrl: 'ui/directive/selectAll/selectAll.html',
  3978. scope: {
  3979. minder: '='
  3980. },
  3981. replace: true,
  3982. link: function($scope) {
  3983. var minder = $scope.minder;
  3984. $scope.items = ['revert', 'siblings', 'level', 'path', 'tree'];
  3985. $scope.select = {
  3986. all: function() {
  3987. var selection = [];
  3988. minder.getRoot().traverse(function(node) {
  3989. selection.push(node);
  3990. });
  3991. minder.select(selection, true);
  3992. minder.fire('receiverfocus');
  3993. },
  3994. revert: function() {
  3995. var selected = minder.getSelectedNodes();
  3996. var selection = [];
  3997. minder.getRoot().traverse(function(node) {
  3998. if (selected.indexOf(node) == -1) {
  3999. selection.push(node);
  4000. }
  4001. });
  4002. minder.select(selection, true);
  4003. minder.fire('receiverfocus');
  4004. },
  4005. siblings: function() {
  4006. var selected = minder.getSelectedNodes();
  4007. var selection = [];
  4008. selected.forEach(function(node) {
  4009. if (!node.parent) return;
  4010. node.parent.children.forEach(function(sibling) {
  4011. if (selection.indexOf(sibling) == -1) selection.push(sibling);
  4012. });
  4013. });
  4014. minder.select(selection, true);
  4015. minder.fire('receiverfocus');
  4016. },
  4017. level: function() {
  4018. var selectedLevel = minder.getSelectedNodes().map(function(node) {
  4019. return node.getLevel();
  4020. });
  4021. var selection = [];
  4022. minder.getRoot().traverse(function(node) {
  4023. if (selectedLevel.indexOf(node.getLevel()) != -1) {
  4024. selection.push(node);
  4025. }
  4026. });
  4027. minder.select(selection, true);
  4028. minder.fire('receiverfocus');
  4029. },
  4030. path: function() {
  4031. var selected = minder.getSelectedNodes();
  4032. var selection = [];
  4033. selected.forEach(function(node) {
  4034. while(node && selection.indexOf(node) == -1) {
  4035. selection.push(node);
  4036. node = node.parent;
  4037. }
  4038. });
  4039. minder.select(selection, true);
  4040. minder.fire('receiverfocus');
  4041. },
  4042. tree: function() {
  4043. var selected = minder.getSelectedNodes();
  4044. var selection = [];
  4045. selected.forEach(function(parent) {
  4046. parent.traverse(function(node) {
  4047. if (selection.indexOf(node) == -1) selection.push(node);
  4048. });
  4049. });
  4050. minder.select(selection, true);
  4051. minder.fire('receiverfocus');
  4052. }
  4053. };
  4054. }
  4055. }
  4056. });
  4057. angular.module('kityminderEditor')
  4058. .directive('styleOperator', function() {
  4059. return {
  4060. restrict: 'E',
  4061. templateUrl: 'ui/directive/styleOperator/styleOperator.html',
  4062. scope: {
  4063. minder: '='
  4064. },
  4065. replace: true
  4066. }
  4067. });
  4068. angular.module('kityminderEditor')
  4069. .directive('templateList', function() {
  4070. return {
  4071. restrict: 'E',
  4072. templateUrl: 'ui/directive/templateList/templateList.html',
  4073. scope: {
  4074. minder: '='
  4075. },
  4076. replace: true,
  4077. link: function($scope) {
  4078. $scope.templateList = kityminder.Minder.getTemplateList();
  4079. }
  4080. }
  4081. });
  4082. angular.module('kityminderEditor')
  4083. .directive('themeList', function() {
  4084. return {
  4085. restrict: 'E',
  4086. templateUrl: 'ui/directive/themeList/themeList.html',
  4087. replace: true,
  4088. link: function($scope) {
  4089. var themeList = kityminder.Minder.getThemeList();
  4090. //$scope.themeList = themeList;
  4091. $scope.getThemeThumbStyle = function (theme) {
  4092. var themeObj = themeList[theme];
  4093. if (!themeObj) {
  4094. return;
  4095. }
  4096. var style = {
  4097. 'color': themeObj['root-color'],
  4098. 'border-radius': themeObj['root-radius'] / 2
  4099. };
  4100. if (themeObj['root-background']) {
  4101. style['background'] = themeObj['root-background'].toString();
  4102. }
  4103. return style;
  4104. };
  4105. // 维护 theme key 列表以保证列表美观(不按字母顺序排序)
  4106. $scope.themeKeyList = [
  4107. 'classic',
  4108. 'classic-compact',
  4109. 'fresh-blue',
  4110. 'fresh-blue-compat',
  4111. 'fresh-green',
  4112. 'fresh-green-compat',
  4113. 'fresh-pink',
  4114. 'fresh-pink-compat',
  4115. 'fresh-purple',
  4116. 'fresh-purple-compat',
  4117. 'fresh-red',
  4118. 'fresh-red-compat',
  4119. 'fresh-soil',
  4120. 'fresh-soil-compat',
  4121. 'snow',
  4122. 'snow-compact',
  4123. 'tianpan',
  4124. 'tianpan-compact',
  4125. 'fish',
  4126. 'wire'
  4127. ];
  4128. }
  4129. }
  4130. });
  4131. angular.module('kityminderEditor')
  4132. .directive('topTab', function() {
  4133. return {
  4134. restrict: 'A',
  4135. templateUrl: 'ui/directive/topTab/topTab.html',
  4136. scope: {
  4137. minder: '=topTab',
  4138. editor: '='
  4139. },
  4140. link: function(scope) {
  4141. /*
  4142. *
  4143. * 用户选择一个新的选项卡会执行 setCurTab 和 foldTopTab 两个函数
  4144. * 用户点击原来的选项卡会执行 foldTopTop 一个函数
  4145. *
  4146. * 也就是每次选择新的选项卡都会执行 setCurTab,初始化的时候也会执行 setCurTab 函数
  4147. * 因此用 executedCurTab 记录是否已经执行了 setCurTab 函数
  4148. * 用 isInit 记录是否是初始化的状态,在任意一个函数时候 isInit 设置为 false
  4149. * 用 isOpen 记录是否打开了 topTab
  4150. *
  4151. * 因此用到了三个 mutex
  4152. * */
  4153. var executedCurTab = false;
  4154. var isInit = true;
  4155. var isOpen = true;
  4156. scope.setCurTab = function(tabName) {
  4157. setTimeout(function() {
  4158. //console.log('set cur tab to : ' + tabName);
  4159. executedCurTab = true;
  4160. //isOpen = false;
  4161. if (tabName != 'idea') {
  4162. isInit = false;
  4163. }
  4164. });
  4165. };
  4166. scope.toggleTopTab = function() {
  4167. setTimeout(function() {
  4168. if(!executedCurTab || isInit) {
  4169. isInit = false;
  4170. isOpen ? closeTopTab(): openTopTab();
  4171. isOpen = !isOpen;
  4172. }
  4173. executedCurTab = false;
  4174. });
  4175. };
  4176. function closeTopTab() {
  4177. var $tabContent = $('.tab-content');
  4178. var $minderEditor = $('.minder-editor');
  4179. $tabContent.animate({
  4180. height: 0,
  4181. display: 'none'
  4182. });
  4183. $minderEditor.animate({
  4184. top: '32px'
  4185. });
  4186. }
  4187. function openTopTab() {
  4188. var $tabContent = $('.tab-content');
  4189. var $minderEditor = $('.minder-editor');
  4190. $tabContent.animate({
  4191. height: '60px',
  4192. display: 'block'
  4193. });
  4194. $minderEditor.animate({
  4195. top: '92px'
  4196. });
  4197. }
  4198. }
  4199. }
  4200. });
  4201. angular.module('kityminderEditor')
  4202. .directive('undoRedo', function() {
  4203. return {
  4204. restrict: 'E',
  4205. templateUrl: 'ui/directive/undoRedo/undoRedo.html',
  4206. scope: {
  4207. editor: '='
  4208. },
  4209. replace: true,
  4210. link: function($scope) {
  4211. }
  4212. }
  4213. });
  4214. use('expose-editor');
  4215. })();