안녕하세요.
라이믹스(혹은 ckeditor)에서 내용 없이 빈 span 태그는 삭제가 잘 됩니다만 안에 내용이 있을 경우 style이나 기타 attribute가 없더라도(<span>만 있을 경우) 삭제되지 않고 남아 있습니다.
이를 없앨 수 있는 방법이 있을까요?
그러니까
<p><span>텍스트</span></p>
(혹은 <p><span><span>텍스트</span></span></p>)
를
<p>텍스트</p>
로 정리하고 싶습니다.
참고로 유저들이 한글 등 워드프로세서나 웹에서 복사한 글을 그대로 붙여 넣을 경우 붙는 쓸모없는 태그를 삭제하고 싶어 ckeditor의 config.js 파일에
config.disallowedContent = 'span[*lang*]{font-family,text-decoration,text-autospace,*spacing,white-space,text-transform,line-height}';
를 넣었기 때문에 생기는 상황입니다.
감사합니다.
ckeditor 일 경우 modules/editor/skins/ckeditor/editor.html 파일에 아래의 스크립트를 추가해 보세요.
<script>
var empty_span= xe.createPlugin("empty_span", {
API_BEFORE_VALIDATE : function(sender, params) {
$isEditorContent = jQuery(params[0]).find('input[name=content]');
if(!$isEditorContent.length) return true;
var editerValue = jQuery(params[0]).find('input[name=content]').val();
editerValue = editerValue.replace("<span>","");
editerValue = editerValue.replace("</span>","");
jQuery(params[0]).find('input[name=content]').val(editerValue);
return true;
}
});
jQuery(function($){
var oEmpty_span = new empty_span();
xe.getApp("Validator")[0].registerPlugin(oEmpty_span);
});
</script>