### Rearrange Toolbar Buttons Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/buttons.html Examples showing the markup before and after moving the superscript and subscript buttons before the left-align button. ```html
  • … 배경 색 레이어 HTML 코드 …
  • ``` -------------------------------- ### Implement Standalone Toolbar Button Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/buttons.html Example of a button that exists alone in a group, which must also include the _buttonRound class. ```html ``` -------------------------------- ### Callback Page HTML Example Source: https://naver.github.io/smarteditor2/user_guide/5_fileuploader/workflow.html This HTML file serves as a callback page for file uploads. It sets the document domain, parses URL parameters, and executes success or error callback functions in the parent FileUploader object. ```html FileUploader Callback ``` -------------------------------- ### Initialize SmartEditor2 Source: https://naver.github.io/smarteditor2/user_guide/2_install/setting.html Create the editor instance using the HuskyEZCreator. Ensure the sSkinURI points to the correct SmartEditor2Skin.html file. ```javascript ``` -------------------------------- ### Perform Initialization After App Ready with $ON_MSG_APP_READY Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/03.html Execute initialization tasks after all plugins are registered using the $ON_MSG_APP_READY handler. This handler should only perform HTML element initialization and event binding, as it impacts editor initialization. ```javascript $ON_MSG_APP_READY : function() { this.oApp.exec('REGISTER_UI_EVENT', ['TimeStamper', 'click', 'SE_TOGGLE_TIMESTAMPER_LAYER']); }, ``` -------------------------------- ### Initialize jindo.FileUploader Source: https://naver.github.io/smarteditor2/user_guide/5_fileuploader/init.html Instantiate jindo.FileUploader with the ID of the file input element and configuration options including the server URL and callback page. ```javascript var oFileUploader = new jindo.FileUploader(jindo.$("file_select"), { //업로드할 서버의 URL(Form 전송 대상) sUrl : '/samples/response/FileUpload.php', //업로드 이후에 IFRMAME이 리다이렉트될 콜백 페이지 주소 sCallback : '/Jindo_Component/FileUploader/callback.html', //post할 데이터 셋. 예: { blogId : "testid" } htData : {} }); ``` -------------------------------- ### Update HuskyEZCreator.js Path Source: https://naver.github.io/smarteditor2/user_guide/2_install/upgrade.html Change the path to HuskyEZCreator.js in write_se2.html to reflect the new location in the 'se2' folder. ```html ``` -------------------------------- ### Include HuskyEZCreator script Source: https://naver.github.io/smarteditor2/user_guide/2_install/setting.html Add the required JavaScript file to the HTML page. Ensure the path to HuskyEZCreator.js is correct. ```html ``` -------------------------------- ### Initialize Plugin with $init Handler Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/03.html Use the $init function for plugin initialization when it's created. This function is called once during the plugin's lifecycle. ```javascript $init : function(elAppContainer){ this._assignHTMLObjects(elAppContainer); }, ``` -------------------------------- ### SE2BasicCreator.js에서 플러그인 등록 제거 Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/remove.html 에디터 초기화 시 로드되는 플러그인 등록 코드를 삭제하여 기능을 비활성화합니다. ```javascript oEditor.registerPlugin(new nhn.husky.SE2M_Quote(elAppContainer)); // 인용구 스타일 oEditor.registerPlugin(new nhn.husky.SE2M_Hyperlink(elAppContainer)); // 하이퍼링크 oEditor.registerPlugin(new nhn.husky.SE2M_SCharacter(elAppContainer)); // 특수 문자 oEditor.registerPlugin(new nhn.husky.SE2M_FindReplacePlugin(elAppContainer));//찾기/바꾸기 oEditor.registerPlugin(new nhn.husky.SE2M_TableCreator(elAppContainer)); // 테이블 생성 oEditor.registerPlugin(new nhn.husky.SE2M_TableEditor(elAppContainer)); // 테이블 편집 oEditor.registerPlugin(new nhn.husky.SE2M_TableBlockStyler(elAppContainer));// 테이블 스타일 ``` -------------------------------- ### 에디터 데이터 전송 형식 예시 Source: https://naver.github.io/smarteditor2/user_guide/4_photouploader/install/04.html setPhotoToEditor 함수를 통해 에디터로 전달되는 데이터는 파일명, 전체 경로, 줄바꿈 여부를 포함하는 배열 구조를 가집니다. ```javascript var res =[ {sFileName : "코코몽.jpg", sFileURL :"http://image_server.domain.net/20120315/코코몽.jpg", bNewLine : true }, {sFileName : "오몽.jpg", sFileURL :" http://image_server.domain.net/20120315/오몽.jpg", bNewLine : true }, … ]; ``` -------------------------------- ### Updated File Structure After Copying Source: https://naver.github.io/smarteditor2/user_guide/2_install/upgrade.html The file structure after creating the 'se2' folder and copying SmartEditor2 files. ```html /pages sample.php write.html write_se2.html -- write.html 을 복사한 파일 /se /css /img /js Husky.SE_Basic.js HuskyEZCreator.js jindo.min.js SE_CustomPlugins.js se_blank.html SEditorSkin.html /se2 -- 새로 추가된 폴더 /css -- 에디터 관련 CSS들 /img -- 에디터 관련 이미지들 /js -- 에디터 관련 JavaScript 파일들 smart_editor2_inputarea.html smart_editor2_inputarea_ie8.html SmartEditor2Skin.html ``` -------------------------------- ### Create SmartEditor2 Instance Source: https://naver.github.io/smarteditor2/user_guide/2_install/upgrade.html Modify the JavaScript code in write_se2.html to create the SmartEditor2 instance, updating the skin URI and creator function name. ```javascript var oEditors = []; nhn.husky.EZCreator.createInIFrame({ oAppRef: oEditors, elPlaceHolder: "ir1", sSkinURI: "../se2/SmartEditor2Skin.html", fCreator: "createSEditor2" }); ``` -------------------------------- ### HTML5 브라우저용 업로드 함수 구현 Source: https://naver.github.io/smarteditor2/user_guide/4_photouploader/install/04.html html5Upload 함수는 선택된 파일들을 순회하며 callAjaxForHTML5를 통해 서버로 전송합니다. callAjaxForHTML5는 Jindo $Ajax를 사용하여 multipart/form-data 형식으로 파일을 업로드합니다. ```javascript function html5Upload() { var tempFile, sUploadURL; //업로드할 URL 입력 sUploadURL= 'file_uploader_html5.php'; //여러 파일이 선택 되었을 때, 파일을 하나씩 보내고 결과를 받음. for(var j=0, k=0; j < nImageInfoCnt; j++) { tempFile = htImageInfo['img'+j]; try{ if(!!tempFile){ //Ajax통신하는 부분. 파일과 업로드 할 url을 전달한다. callAjaxForHTML5(tempFile,sUploadURL); k += 1; } }catch(e){} tempFile = null; } } function callAjaxForHTML5 (tempFile, sUploadURL){ var oAjax = jindo.$Ajax(sUploadURL, { type: 'xhr', method : "post", onload : function(res){ // 요청이 완료되면 실행될 콜백 함수 if (res.readyState() == 4) { //성공 시에 responseText를 가지고 array로 만드는 부분. makeArrayFromString(res._response.responseText); } }, timeout : 3, onerror : jindo.$Fn(onAjaxError, this).bind() }); oAjax.header("contentType","multipart/form-data"); oAjax.header("file-name",encodeURIComponent(tempFile.name)); oAjax.header("file-size",tempFile.size); oAjax.header("file-Type",tempFile.type); oAjax.request(tempFile); } ``` -------------------------------- ### Configure Popup URL in hp_SE2M_AttachQuickPhoto.js Source: https://naver.github.io/smarteditor2/user_guide/4_photouploader/install/01.html Modify the makePopupURL function to point to the correct photo uploader HTML file path. ```javascript /** * 서비스별로 팝업에 parameter를 추가하여 URL을 생성하는 함수 */ makePopupURL : function(){ var sPopupUrl = "./popup/attach_photo/photo_uploader.html"; return sPopupUrl; }, ``` -------------------------------- ### SmartEditor2 Files to Copy Source: https://naver.github.io/smarteditor2/user_guide/2_install/upgrade.html Files and folders to copy from the SmartEditor2 distribution into a new 'se2' folder. ```html /css /img /js smart_editor2_inputarea.html smart_editor2_inputarea_ie8.html SmartEditor2Skin.html ``` -------------------------------- ### Initialize HTML Elements with _assignHTMLElements Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/03.html Initialize frequently used HTML elements within the _assignHTMLElements function. For performance-critical elements, consider initializing them only when needed. ```javascript _assignHTMLObjects : function(elAppContainer){ this.oDropdownLayer = cssquery.getSingle("DIV.husky_seditor_TimeStamper_layer", elAppContainer); }, ``` -------------------------------- ### Configure file_uploader_html5.php for Photo Upload Source: https://naver.github.io/smarteditor2/user_guide/4_photouploader/install/03.html Update the file_uploader_html5.php script to correctly save uploaded files and set the file URL. Verify that the sFileURL path points to the correct server upload location. ```php if(file_put_contents($newPath, $file->content)) { $sFileInfo .= "&bNewLine=true"; $sFileInfo .= "&sFileName=".$file->name; $sFileInfo .= "&sFileURL=/smarteditor/demo/uploade/". ``` -------------------------------- ### Register Photo Plugin in SE2BasicCreator.js Source: https://naver.github.io/smarteditor2/user_guide/4_photouploader/install/01.html Add the photo plugin instance to the editor container within the creator script. ```javascript oEditor.registerPlugin(new nhn.husky.SE2M_AttachQuickPhoto(elAppContainer)); // 사진 ``` -------------------------------- ### Complete SE_TimeStamper Plugin Code Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/03.html This is the complete JavaScript code for the SE_TimeStamper plugin, demonstrating how to integrate initialization, UI event registration, and custom handler logic. ```javascript nhn.husky.SE_TimeStamper = jindo.$Class({ name : "SE_TimeStamper", $init : function(elAppContainer){ this._assignHTMLObjects(elAppContainer); }, _assignHTMLObjects : function(elAppContainer){ this.oDropdownLayer = cssquery.getSingle("DIV.husky_seditor_TimeStamper_layer", elAppContainer); //div 레이어안에 있는 input button을 cssquery로 찾는 부분. this.oInputButton = cssquery.getSingle(".se_button_time", elAppContainer); }, $ON_MSG_APP_READY : function(){ this.oApp.exec("REGISTER_UI_EVENT", ["TimeStamper", "click", "SE_TOGGLE_TIMESTAMPER_LAYER"]); //input button에 click 이벤트를 할당. this.oApp.registerBrowserEvent(this.oInputButton, 'click','PASTE_NOW_DATE'); }, $ON_SE_TOGGLE_TIMESTAMPER_LAYER : function(){ this.oApp.exec("TOGGLE_TOOLBAR_ACTIVE_LAYER", [this.oDropdownLayer]); }, $ON_PASTE_NOW_DATE : function(){ this.oApp.exec("PASTE_HTML", [new Date()]); } }); ``` -------------------------------- ### jindo.FileUploader Methods Source: https://naver.github.io/smarteditor2/user_guide/5_fileuploader/methods.html The jindo.FileUploader component provides the following methods for file upload functionality. ```APIDOC ## jindo.FileUploader Methods ### Description This section details the methods available for the jindo.FileUploader component. ### Methods - **getFileSelect** - **Description**: Retrieves the File Select element. - **Return Value**: HTMLElement - **getFormElement** - **Description**: Retrieves the Form element associated with the File Select. - **Return Value**: HTMLElement - **reset** - **Description**: Resets the selected file values in the File Select. - **Return Value**: None - **upload** - **Description**: Performs the upload using an IFRAME. - **Return Value**: None ``` -------------------------------- ### SmartEditor2Skin.html에서 UI 마크업 삭제 Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/remove.html 사용하지 않는 기능의 버튼과 레이어 마크업을 HTML 파일에서 제거합니다. ```html
  • ``` -------------------------------- ### Define a Husky Plugin Class Source: https://naver.github.io/smarteditor2/user_guide/3_customizing Use the nhn.husky namespace when defining a new plugin class with jindo.$Class. ```javascript nhn.husky.SE2_TimeStamper = jindo.$Class({ ... }); ``` -------------------------------- ### Integrate Button into SmartEditor2Skin.html Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/01.html Insert the new button markup into the appropriate ul element within the husky_seditor_text_tool container in SmartEditor2Skin.html. ```html
    … 생략 …
    ``` -------------------------------- ### Register Plugin in SE2BasicCreator.js Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/02.html Register the plugin instance within the SE2BasicCreator.js file, typically at the end of the file. ```javascript oEditor.registerPlugin(new nhn.husky.SE_TimeStamper(elAppContainer)); ``` -------------------------------- ### Define Toolbar Button with Layer Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/01.html Include a hidden div with the se2_layer class after the button element to display a layer upon interaction. ```html
  • ``` -------------------------------- ### Handle Success Event Source: https://naver.github.io/smarteditor2/user_guide/5_fileuploader/events.html Attaches a listener to the success event to handle successful file uploads. ```javascript oComponent.attach("success", function(oCustomEvent) { ... }); ``` -------------------------------- ### Add textarea for editor Source: https://naver.github.io/smarteditor2/user_guide/2_install/setting.html Define the textarea element where the editor will be initialized. The editor content is synchronized with this element's value. ```html ``` -------------------------------- ### Add Plugin Script to SmartEditor2Skin.htm Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/02.html Include the JavaScript file path for the plugin in the skin file, preferably below the smarteditor2.js declaration. ```html ``` -------------------------------- ### Define Toolbar Button CSS Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/01.html Add the background image definition for the new toolbar button to the smart_editor2.css file. ```css #smart_editor2 .se2_text_tool .se2_clock { background:url("../img/clock.png") no-repeat }; ``` -------------------------------- ### Configure file_uploader.php for Photo Upload Source: https://naver.github.io/smarteditor2/user_guide/4_photouploader/install/03.html Modify the file_uploader.php file to correctly set the upload URL and filename for SmartEditor2. Ensure the sFileURL path matches your server's upload directory. ```php $url .= "&bNewLine=true"; $url .= "&sFileName=".urlencode(urlencode($name)); $url .= "&sFileURL=/smarteditor/demo/upload/".urlencode(urlencode($name)); ``` -------------------------------- ### Include Plugin Script in SmartEditor2Skin.html Source: https://naver.github.io/smarteditor2/user_guide/4_photouploader/install/01.html Declare the plugin JavaScript file in the editor skin HTML file. ```html ``` -------------------------------- ### Handle Browser Events with EVENT_ Prefix Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/03.html Name handlers for direct browser events by prefixing them with EVENT_. This convention helps distinguish event handlers from other message handlers. ```javascript $ON_EVENT_EDITING_AREA_KEYUP ``` -------------------------------- ### Notify on Events with MSG_ Prefix Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/03.html Use the MSG_ prefix for handlers that are notified of specific events rather than performing a mandatory task. This is useful for decoupling components and reacting to editor states. ```javascript $ON_MSG_EDITOR_READY ``` -------------------------------- ### jindo.FileUploader Custom Events Source: https://naver.github.io/smarteditor2/user_guide/5_fileuploader/events.html This section describes the custom events provided by jindo.FileUploader, which are triggered during file selection and upload processes. ```APIDOC ## Custom Events ### sUploadURL **Description**: Triggered when file selection is complete. **Properties**: - **sType** (String) - The name of the custom event. - **sValue** (String) - The value of the selected file input. - **bAllowed** (Boolean) - Indicates if the selected file format is allowed. If false, a warning message specified in `sMsgNotAllowedExt` is displayed. - **sMsgNotAllowedExt** (String) - The warning message to display when the selected file format is not allowed. - **stop** (Function) - If called, stops all further processing, regardless of the `bAllowed` value. ### onload **Description**: Indicates that the upload was successful. **Usage Example**: ```javascript oComponent.attach("success", function(oCustomEvent) { ... }); ``` **Properties**: - **sType** (String) - The name of the custom event. - **htResult** (HashTable) - The result object returned by the server. This can be configured dynamically based on server settings. ### onerror **Description**: Indicates that the upload failed. **Usage Example**: ```javascript oComponent.attach("error", function(oCustomEvent) { ... }); ``` **Properties**: - **sType** (String) - The name of the custom event. - **htResult** (HashTable) - The result object returned by the server. When an error occurs, this must include an `errstr` property containing the error message string. ``` -------------------------------- ### Insert Current Date with PASTE_NOW_DATE Handler Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/plugins/03.html Create the PASTE_NOW_DATE handler to insert the current date into the editor's content. This handler utilizes the PASTE_HTML editor command. ```javascript $ON_PASTE_NOW_DATE : function(){ this.oApp.exec("PASTE_HTML", [new Date()]); } ``` -------------------------------- ### Add or change class handlers Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/override.html Use this pattern to define or override specific event handlers within a class. ```javascript nhn.husky.SE2M_AttachFile.prototype.$ON_ATTACHFILE_OPEN_WINDOW = function () { var url = …; … window.open(url, …); }; ``` -------------------------------- ### SmartEditor2 툴바 버튼 제거 전후 비교 Source: https://naver.github.io/smarteditor2/user_guide/3_customizing/buttons.html 링크 버튼을 제거하기 전의 HTML 구조와 제거 후의 변경된 구조를 보여줍니다. ```html