ERROR/WEB
[html/스마트에디터]<p><br></p> 문제
onlyun
2024. 5. 17. 16:23
웹 에디터로,
스마트에디터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> <\/P>');
//240517, 아래 내용 주석 처리
/*if (!jindo.$Agent().navigator().ie) {
oContent.append('<P><BR></P>');
} else {
oContent.append('<P> <\/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();
};
...
}
}