You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
6.8 KiB

7 years ago
  1. /*
  2. Copyright (C) NAVER corp.
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with this library; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  14. */
  15. function createSEditor2(elIRField, htParams, elSeAppContainer){
  16. if(!window.$Jindo){
  17. parent.document.body.innerHTML="진도 프레임웍이 필요합니다.<br>\n<a href='http://dev.naver.com/projects/jindo/download'>http://dev.naver.com/projects/jindo/download</a>에서 Jindo 1.5.3 버전의 jindo.min.js를 다운로드 받아 /js 폴더에 복사 해 주세요.\n(아직 Jindo 2 는 지원하지 않습니다.)";
  18. return;
  19. }
  20. var elAppContainer = (elSeAppContainer || jindo.$("smart_editor2"));
  21. var elEditingArea = jindo.$$.getSingle("DIV.husky_seditor_editing_area_container", elAppContainer);
  22. var oWYSIWYGIFrame = jindo.$$.getSingle("IFRAME.se2_input_wysiwyg", elEditingArea);
  23. var oIRTextarea = elIRField?elIRField:jindo.$$.getSingle("TEXTAREA.blind", elEditingArea);
  24. var oHTMLSrc = jindo.$$.getSingle("TEXTAREA.se2_input_htmlsrc", elEditingArea);
  25. var oTextArea = jindo.$$.getSingle("TEXTAREA.se2_input_text", elEditingArea);
  26. if(!htParams){
  27. htParams = {};
  28. htParams.fOnBeforeUnload = null;
  29. }
  30. htParams.elAppContainer = elAppContainer; // 에디터 UI 최상위 element 셋팅
  31. htParams.oNavigator = jindo.$Agent().navigator(); // navigator 객체 셋팅
  32. htParams.I18N_LOCALE = htParams.I18N_LOCALE || "ko_KR";
  33. var oEditor = new nhn.husky.HuskyCore(htParams);
  34. oEditor.registerPlugin(new nhn.husky.CorePlugin(htParams?htParams.fOnAppLoad:null));
  35. oEditor.registerPlugin(new nhn.husky.StringConverterManager());
  36. if(htParams.bSkipXssFilter !== true){
  37. // 보안 필터링 플러그인 (TODO:소스분리 및 블랙리스트 옵션 추가)
  38. oEditor.registerPlugin({
  39. _rxFilter:/<\/*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*?>/gi,
  40. $ON_REGISTER_CONVERTERS : function() {
  41. var fXssFilter = jindo.$Fn(function(sHtml){
  42. return sHtml.replace(this._rxFilter, "");
  43. }, this).bind();
  44. this.oApp.exec("ADD_CONVERTER",["HTMLSrc_TO_IR", fXssFilter]);
  45. this.oApp.exec("ADD_CONVERTER",["IR_TO_DB", fXssFilter]);
  46. }
  47. });
  48. }
  49. var htDimension = {
  50. nMinHeight:205,
  51. nMinWidth:parseInt(elIRField.style.minWidth, 10)||570,
  52. nHeight:elIRField.style.height||elIRField.offsetHeight,
  53. nWidth:elIRField.style.width||elIRField.offsetWidth
  54. };
  55. var htConversionMode = {
  56. bUseVerticalResizer : htParams.bUseVerticalResizer,
  57. bUseModeChanger : htParams.bUseModeChanger
  58. };
  59. var aAdditionalFontList = htParams.aAdditionalFontList;
  60. oEditor.registerPlugin(new nhn.husky.SE_EditingAreaManager("WYSIWYG", oIRTextarea, htDimension, htParams.fOnBeforeUnload, elAppContainer));
  61. oEditor.registerPlugin(new nhn.husky.SE_EditingArea_WYSIWYG(oWYSIWYGIFrame)); // Tab Editor 모드
  62. oEditor.registerPlugin(new nhn.husky.SE_EditingArea_HTMLSrc(oHTMLSrc)); // Tab HTML 모드
  63. oEditor.registerPlugin(new nhn.husky.SE_EditingArea_TEXT(oTextArea)); // Tab Text 모드
  64. oEditor.registerPlugin(new nhn.husky.SE2M_EditingModeChanger(elAppContainer, htConversionMode)); // 모드간 변경(Editor, HTML, Text)
  65. oEditor.registerPlugin(new nhn.husky.SE_PasteHandler()); // WYSIWYG Paste Handler
  66. oEditor.registerPlugin(new nhn.husky.HuskyRangeManager(oWYSIWYGIFrame));
  67. oEditor.registerPlugin(new nhn.husky.Utils());
  68. oEditor.registerPlugin(new nhn.husky.SE2M_UtilPlugin());
  69. oEditor.registerPlugin(new nhn.husky.SE_WYSIWYGStyler());
  70. oEditor.registerPlugin(new nhn.husky.SE2M_Toolbar(elAppContainer));
  71. oEditor.registerPlugin(new nhn.husky.Hotkey()); // 단축키
  72. oEditor.registerPlugin(new nhn.husky.SE_EditingAreaVerticalResizer(elAppContainer, htConversionMode)); // 편집영역 리사이즈
  73. oEditor.registerPlugin(new nhn.husky.DialogLayerManager());
  74. oEditor.registerPlugin(new nhn.husky.ActiveLayerManager());
  75. oEditor.registerPlugin(new nhn.husky.SE_WYSIWYGStyleGetter()); // 커서 위치 스타일 정보 가져오기
  76. oEditor.registerPlugin(new nhn.husky.SE_WYSIWYGEnterKey("P")); // 엔터 시 처리, 현재는 P로 처리
  77. oEditor.registerPlugin(new nhn.husky.SE2M_ColorPalette(elAppContainer)); // 색상 팔레트
  78. oEditor.registerPlugin(new nhn.husky.SE2M_FontColor(elAppContainer)); // 글자색
  79. oEditor.registerPlugin(new nhn.husky.SE2M_BGColor(elAppContainer)); // 글자배경색
  80. oEditor.registerPlugin(new nhn.husky.SE2M_FontNameWithLayerUI(elAppContainer, aAdditionalFontList)); // 글꼴종류
  81. oEditor.registerPlugin(new nhn.husky.SE2M_FontSizeWithLayerUI(elAppContainer)); // 글꼴크기
  82. oEditor.registerPlugin(new nhn.husky.SE2M_LineStyler());
  83. oEditor.registerPlugin(new nhn.husky.SE2M_ExecCommand(oWYSIWYGIFrame));
  84. oEditor.registerPlugin(new nhn.husky.SE2M_LineHeightWithLayerUI(elAppContainer)); // 줄간격
  85. oEditor.registerPlugin(new nhn.husky.SE2M_Quote(elAppContainer)); // 인용구
  86. oEditor.registerPlugin(new nhn.husky.SE2M_Hyperlink(elAppContainer)); // 링크
  87. oEditor.registerPlugin(new nhn.husky.SE2M_SCharacter(elAppContainer)); // 특수문자
  88. oEditor.registerPlugin(new nhn.husky.SE2M_FindReplacePlugin(elAppContainer)); // 찾기/바꾸기
  89. oEditor.registerPlugin(new nhn.husky.SE2M_TableCreator(elAppContainer)); // 테이블 생성
  90. oEditor.registerPlugin(new nhn.husky.SE2M_TableEditor(elAppContainer)); // 테이블 편집
  91. oEditor.registerPlugin(new nhn.husky.SE2M_TableBlockStyler(elAppContainer)); // 테이블 스타일
  92. if(nhn.husky.SE2M_AttachQuickPhoto){
  93. oEditor.registerPlugin(new nhn.husky.SE2M_AttachQuickPhoto(elAppContainer)); // 사진
  94. }
  95. oEditor.registerPlugin(new nhn.husky.MessageManager(oMessageMap, htParams.I18N_LOCALE));
  96. oEditor.registerPlugin(new nhn.husky.SE2M_QuickEditor_Common(elAppContainer)); // 퀵에디터 공통(표, 이미지)
  97. oEditor.registerPlugin(new nhn.husky.SE2B_CSSLoader()); // CSS lazy load
  98. if(window.frameElement){
  99. oEditor.registerPlugin(new nhn.husky.SE_OuterIFrameControl(elAppContainer, 100));
  100. }
  101. oEditor.registerPlugin(new nhn.husky.SE_ToolbarToggler(elAppContainer, htParams.bUseToolbar));
  102. oEditor.registerPlugin(new nhn.husky.SE2M_Accessibility(elAppContainer, htParams.I18N_LOCALE)); // 에디터내의 웹접근성 관련 기능모음 플러그인
  103. return oEditor;
  104. }