필터 추가

1. IE에서 표준 태그를 만들어내도록 하는 필터 추가(plz_standard)
2. 이미지 경로에서 request_uri를 제거하는 필터 추가(remove_baseurl)


git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7935 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2010-11-29 08:50:14 +00:00
parent 99100af72f
commit d7d6d7ec15
2 changed files with 82 additions and 12 deletions

View file

@ -27,6 +27,10 @@ function editorStart_xe(editor_seq, primary_key, content_key, editor_height, col
// create an editor
xe.Editors[editor_seq] = xeed = new xe.Xeed($textarea, opt);
xe.registerApp(xeed);
// filters
xeed.cast('REGISTER_FILTER', ['r2t', plz_standard]);
//xeed.cast('REGISTER_FILTER', ['r2t', remove_baseurl]);
// Set standard API
editorRelKeys[editor_seq] = {
@ -43,6 +47,39 @@ function editorStart_xe(editor_seq, primary_key, content_key, editor_height, col
return xeed;
}
// standard filters
function plz_standard(code) {
var single_tags = 'img input'.split(' ');
code = code.replace(/<(\/)?([A-Za-z0-9:]+)(.*?)(\s*\/?)>/g, function(m0,is_close,tag,attrs,closing){
tag = tag.toLowerCase();
attrs = attrs.replace(/([\w:-]\s*)=(?:([^"' \t\r\n]+)|\s*("[^"]*")|\s*('[^']*'))/g, function(m0,name,m2,m3,m4){
var val = m2||m3||m4;
if (m3||m4) val = val.substr(1,val.length-2);
return $.trim(name.toLowerCase())+'='+'"'+val+'"';
});
if (attrs=$.trim(attrs)) attrs = ' '+attrs;
closing = $.trim(closing);
if (!is_close && !closing && $.inArray(tag, single_tags) != -1) closing = ' /';
return '<'+(is_close||'')+tag+attrs+closing+'>';
});
return code;
}
// remove base url
function remove_baseurl(code) {
var reg = new RegExp(' (href|src)\s*=\s*(["\'])?'+request_uri.replace('\\', '\\\\'), 'ig');
return code.replace(reg, function(m0,m1,m2){ return ' '+m1+'='+m2; });
}
window.editorStart_xe = editorStart_xe;
})(jQuery);