mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 19:51:42 +09:00
#18532314 인라인 요소만으로 이루어진 문서일 때, 문단 태그(p)가 적용 되어 있지 않으면, 전체을 감싸도록 하고, XHTML태그명, 요소 명은 소문자로 쓰도록 함.
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7139 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
0b84da8318
commit
2fc7a17b06
1 changed files with 21 additions and 6 deletions
|
|
@ -156,27 +156,42 @@ function editorGetContentTextarea_xe(editor_sequence) {
|
|||
|
||||
if(!jQuery.trim(str.replace(/( |<\/?(p|br|span|div)([^>]+)?>)/ig, ''))) return '';
|
||||
|
||||
// 파이어폭스의 경우 의미없는 <br>이 컨텐트 마지막에 추가될 수 있다.
|
||||
str = str.replace(/<br ?\/?>$/i, '');
|
||||
|
||||
// 속도 문제가 있으므로 1024 문자 미만일 때만 첫 노드가 텍스트 노드인지 테스트
|
||||
// 그 이상이면 P 노드가 정상적으로 생성되었다고 가정한다.
|
||||
if (str.length < 1024) {
|
||||
var inline_elements = Array('#text','A','BR','IMG','EM','STRONG','SPAN','BIG','CITE','CODE','DD','DFN','HR','INS','KBD','LINK','Q','SAMP','SMALL','SUB','SUP','TT');
|
||||
var is_inline_contents = true;
|
||||
var div = jQuery('<div>'+str+'</div>').eq(0);
|
||||
var nodes = div.contents();
|
||||
jQuery.each(nodes, function() {
|
||||
if (this.nodeType == 3) {
|
||||
jQuery(this).wrap('<p></p>');
|
||||
if (this.nodeType != 3) {
|
||||
if(jQuery.inArray(this.nodeName, inline_elements ) == -1) {
|
||||
is_inline_contents = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
str = div.html();
|
||||
if(is_inline_contents) str = '<p>'+str+'</p>';
|
||||
}
|
||||
|
||||
// 파이어폭스의 경우 의미없는 <br>이 컨텐트 마지막에 추가될 수 있다.
|
||||
str = str.replace(/<br ?\/?>$/i, '');
|
||||
|
||||
// 이미지 경로를 수정한다. - 20091125
|
||||
str = str.replace(/src\s?=\s?(["']?)(?:\.\.\/)+(files\/attach\/)/ig, function(m0,m1,m2){
|
||||
return 'src='+(m1||'')+m2;
|
||||
});
|
||||
|
||||
str = str.replace(/\<(\/)?([A-Z]+)([^>]*)\>/ig, function(m0,m1,m2,m3) {
|
||||
m3 = m3.replace(/ ([A-Z]+?)\=/g, function(n0,n1) {
|
||||
n1 = n1.toLowerCase();
|
||||
return ' '+n1+'=';
|
||||
});
|
||||
m2 = m2.toLowerCase();
|
||||
if(!m1) m1='';
|
||||
return '<'+m1+m2+m3+'>';
|
||||
});
|
||||
str = str.replace('<br>','<br />');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue