티스토리 뷰

 

웹 에디터로,

스마트에디터2 사용중인데

 

글 등록하면, DB에는 <p><br></p>가 추가되지 않음.

 

근데 웹 페이지에서 저장된 글을  불러오면 <p><br></p>가 붙음.

 

등록한 후, 불러오는 경우에 <p><br></p>가 붙음.

 

방법 1)smarteditor.js 에서, 

<p><br></o> 추가하지 않도록 처리 => 안 됨

//smarteditor2.js
...
	_addLineBreaker : function(sContent){
		if(this.oApp.sLineBreaker === "BR"){
			return sContent.replace(/\r?\n/g, "<BR>");
		}
		
		var oContent = new StringBuffer(),
			aContent = sContent.split('\n'), // \n을 기준으로 블럭을 나눈다.
			aContentLng = aContent.length, 
			sTemp = "";
		
		for (var i = 0; i < aContentLng; i++) {
			sTemp = jindo.$S(aContent[i]).trim().$value();
			if (i === aContentLng -1 && sTemp === "") {
				break;
			}
			
			if (sTemp !== null && sTemp !== "") {
				oContent.append('<P>');
				oContent.append(aContent[i]);
				oContent.append('</P>');
			} else {
				oContent.append('<P>&nbsp;<\/P>'); 
                //240517, 아래 내용 주석 처리
				/*if (!jindo.$Agent().navigator().ie) {
					oContent.append('<P><BR></P>');
				} else {
					oContent.append('<P>&nbsp;<\/P>');
				}*/
			}
		}
		
		return oContent.toString();
	},
...

 

방법 2)

불러올 때, 콘텐츠 clear 처리했는데도 안 됨....

//smart-editor-helper.js
var SE_HELPER = (function () {
    //240517
    // cleanHTML 함수 정의
    const cleanHTML = function(html) {
        return html.replace(/<p><br><\/p>/gi, '');
    };
	// 스마트에디터 로드
    const loadedSmartEditor = function (elId, initContentsValue, callback) {
    // 내부에 추가
    ...
        // 스마트에디터 데이터 get
        const getEditorContentsValue = function (elId) {

            // 초기 셋팅값 설정
            if (!elId || typeof elId !== 'string') {
                elId = DEFAULT_SMART_EDITOR_ID;
            }

            if (!oEditors || !oEditors.length || !oEditors.getById[elId]) {
                alert(' 스마트 에디터가 로드되어있지 않습니다. ');
                return false;
            }

            //240517-content clear
            var content = oEditors.getById[elId].getIR();
            content = cleanHTML(content);  // 내용 정리
            return content;
            //return oEditors.getById[elId].getIR();
        };
     ...
    }
}

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함