1. IE에서 잘못된 " (따옴표 감쌈)이 되는 문제 수정

2. 에디터컴포넌트 더블클릭시 수정 모드 동작하도록 수정
3. 이미지등의 경로가 잘못 처리되는 문제 수정


git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6257 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2009-05-04 04:50:37 +00:00
parent 1b152e7cbe
commit c92421c5ee
2 changed files with 87 additions and 62 deletions

View file

@ -5031,43 +5031,43 @@ xe.XE_Hyperlink = jQuery.Class({
this.oApp.exec("FOCUS", []);
this.oSelection = this.oApp.getSelection();
if(this._validateURL(sURL)){
var sTarget = "";
if(this.oCbNewWin.checked)
sTarget = "_blank";
else
sTarget = "_self";
//if(this._validateURL(sURL)){
var sTarget = "";
if(this.oCbNewWin.checked)
sTarget = "_blank";
else
sTarget = "_self";
if(this.oSelection.collapsed){
var str = "<a href='" + sURL + "' target="+sTarget+">" + sURL + "</a>";
this.oSelection.pasteHTML(str);
}else{
var nSession = Math.ceil(Math.random()*10000);
var arg = ( sURL == "" ? ["unlink"] : ["createLink", false, this.sATagMarker+nSession+sURL] );
this.oApp.exec("EXECCOMMAND", arg);
if(this.oSelection.collapsed){
var str = "<a href='" + sURL + "' target="+sTarget+">" + sURL + "</a>";
this.oSelection.pasteHTML(str);
}else{
var nSession = Math.ceil(Math.random()*10000);
var arg = ( sURL == "" ? ["unlink"] : ["createLink", false, this.sATagMarker+nSession+sURL] );
this.oApp.exec("EXECCOMMAND", arg);
this.oSelection.setFromSelection();
this.oSelection.setFromSelection();
var oDoc = this.oApp.getWYSIWYGDocument();
var aATags = oDoc.body.getElementsByTagName("A");
var nLen = aATags.length;
var rxMarker = new RegExp(this.sRXATagMarker+nSession, "i");
var elATag;
for(var i=0; i<nLen; i++){
elATag = aATags[i];
if(elATag.href && elATag.href.match(rxMarker)){
elATag.href = elATag.href.replace(rxMarker, "");
elATag.target = sTarget;
}
}
}
this.oApp.exec("HIDE_ACTIVE_LAYER");
setTimeout(jQuery.fnBind(function(){this.oSelection.select()}, this), 0);
}else{
alert(this.oApp.$MSG("XE_Hyperlink.invalidURL"));
this.oLinkInput.focus();
}
var oDoc = this.oApp.getWYSIWYGDocument();
var aATags = oDoc.body.getElementsByTagName("A");
var nLen = aATags.length;
var rxMarker = new RegExp(this.sRXATagMarker+nSession, "i");
var elATag;
for(var i=0; i<nLen; i++){
elATag = aATags[i];
if(elATag.href && elATag.href.match(rxMarker)){
elATag.href = elATag.href.replace(rxMarker, "");
elATag.target = sTarget;
}
}
}
this.oApp.exec("HIDE_ACTIVE_LAYER");
setTimeout(jQuery.fnBind(function(){this.oSelection.select()}, this), 0);
//}else{
//alert(this.oApp.$MSG("XE_Hyperlink.invalidURL"));
//this.oLinkInput.focus();
//}
},
_validateURL : function(sURL){
@ -5432,7 +5432,7 @@ var
regex_font_weight = /font-weight\s*:\s*([a-z]+);?/i,
regex_font_style = /font-style\s*:\s*italic;?/i,
regex_font_decoration = /text-decoration\s*:\s*([a-z -]+);?/i,
regex_jquery = /jQuery\d+\s*=(\s*"\d+"|\d+)/g,
regex_jquery = /jQuery\d+\s*=(\s*"\d+"|\d+)/ig,
regex_quote_attr = /([\w-]+\s*=(?:\s*"[^"]+"|\s*'[^']+'))|([\w-]+)=([^\s]+)/g; //"
var
@ -5492,6 +5492,7 @@ xe.XE_XHTMLFormatter = $.Class({
return '<'+m1+' '+
m2.replace(regex_quote_attr, function(s0,s1,s2,s3){
if (s1) return s1;
if(/^"/.test(s3)||/"$/.test(s3)) return s2+'='+s3;
return s2+'="'+s3+'"';
}) + '>';
});
@ -5656,8 +5657,6 @@ xe.XE_Extension = jQuery.Class({
},
_removeAttrs : function(sContent) {
sContent = sContent.replace(/<img([^>]*?) xe_handled\s*=\s*".+?"([^>]*?)>/i, '<img$1 $2>');
return sContent;
},
@ -5666,28 +5665,30 @@ xe.XE_Extension = jQuery.Class({
var doc = this.oApp.getWYSIWYGDocument();
var seq = this.seq;
var prevComponent = null;
var fn = function(){
var obj = jQuery(this);
var comp = obj.attr('editor_component');
if(prevComponent == comp) return false;
prevComponent = comp;
if (comp && jQuery.isFunction(openComponent)) {
editorPrevNode = obj.get(0);
openComponent(comp, seq);
}
setTimeout(500, function() { prevComponent = null; });
};
jQuery('img[editor_component],div[editor_component]', doc).each(function(){
jQuery('img,div[editor_component]', doc).each(function(){
var obj = jQuery(this);
if (!obj.attr('xe_handled')) {
obj.attr('xe_handled', 'yes').dblclick(fn);
}
if(this.nodeName == 'IMG' && !obj.attr('editor_component')) obj.attr('editor_component','image_link')
obj.dblclick(fn);
});
},
$ON_MSG_APP_READY : function() {
this.oApp.exec('REGISTER_UI_EVENT', ['extension', 'click', 'TOGGLE_EXTENSION_LAYER']);
this.oApp.addConverter("WYSIWYG_TO_IR", this._removeAttrs);
},
$ON_TOGGLE_EXTENSION_LAYER : function() {

View file

@ -54,10 +54,15 @@ function editorStart_xe(editor_sequence, primary_key, content_key, editor_height
oEditor.getFrame = function(){ return oWYSIWYGIFrame;}
var content = form[content_key].value;
var srcPathRegx = /src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/g; //'
var hrefPathRegx = /href=("|\'){1}(\.\/)?\?([^"\']+)("|\'){1}/g; //'
content = content.replace(srcPathRegx, 'src="'+request_uri+'$3/$4.$5"');
content = content.replace(hrefPathRegx, 'href="'+request_uri+'?$3"');
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>)*/ig, function(m0,m1,m2,m3,m4,m5) {
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
var val = jQuery.trim(m3).replace(/^\.\//,'');
if(/^(http|https|ftp|telnet|\/|\.\.)/i.test(val)) return m0;
return m1+m2+request_uri+val+m4+m5;
});
form[content_key].value = content;
jQuery("#xpress-editor-"+editor_sequence).val(content);
@ -124,11 +129,11 @@ function editorStart_xe(editor_sequence, primary_key, content_key, editor_height
oEditor.registerPlugin(new xe.XE_WYSIWYGEnterKey(oWYSIWYGIFrame));
}
// 자동 저장 사용?
// 자동 저장 사용
if (s=form._saved_doc_title) {
oEditor.registerPlugin(new xe.XE_AutoSave(oIRTextarea, elAppContainer));
}
function load_proc() {
try {
var doc = oWYSIWYGIFrame.contentWindow.document, str;
@ -170,17 +175,17 @@ function editorGetIframe(srl) {
return jQuery('iframe#editor_iframe_'+srl).get(0);
}
function editorReplaceHTML(iframe_obj, text) {
// 이미지 경로 재지정 (rewrite mod)
var srcPathRegx = /src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/g;//'
text = text.replace(srcPathRegx, 'src="'+request_uri+'$3/$4.$5"');
// href 경로 재지정 (rewrite mod)
var hrefPathRegx = /href=("|\'){1}(\.\/)?\?([^"\']+)("|\'){1}/g;//'
text = text.replace(hrefPathRegx, 'href="'+request_uri+'?$3"');
function editorReplaceHTML(iframe_obj, content) {
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>)*/ig, function(m0,m1,m2,m3,m4,m5) {
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
var val = jQuery.trim(m3).replace(/^\.\//,'');
if(/^(http|https|ftp|telnet|\/|\.\.)/i.test(val)) return m0;
return m1+m2+request_uri+val+m4+m5;
});
var srl = parseInt(iframe_obj.id.replace(/^.*_/,''),10);
editorRelKeys[srl]["pasteHTML"](text);
editorRelKeys[srl]["pasteHTML"](content);
}
// WYSIWYG 모드를 저장하는 확장기능
@ -202,14 +207,33 @@ xe.XE_GET_WYSYWYG_CONTENT = jQuery.Class({
$ON_MSG_APP_READY : function() {
this.oApp.addConverter("IR_TO_WYSIWYG", this.TO_WYSIWYG_SET);
this.oApp.addConverter("IR_TO_HTMLSrc", this.IR_TO_HTMLSrc);
},
TO_WYSIWYG_SET : function(content) {
var srcPathRegx = /src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/g;//'
var hrefPathRegx = /href=("|\'){1}(\.\/)?\?([^"\']+)("|\'){1}/g;//'
content = content.replace(srcPathRegx, 'src="'+request_uri+'$3/$4.$5"');
content = content.replace(hrefPathRegx, 'href="'+request_uri+'?$3"');
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>)*/ig, function(m0,m1,m2,m3,m4,m5) {
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
var val = jQuery.trim(m3).replace(/^\.\//,'');
if(/^(http|https|ftp|telnet|\/|\.\.)/i.test(val)) return m0;
return m1+m2+request_uri+val+m4+m5;
});
return content;
},
IR_TO_HTMLSrc : function(content) {
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>|\))*/ig, function(m0,m1,m2,m3,m4,m5) {
var uriReg = new RegExp('^'+request_uri.replace('\/','\\/'),'ig');
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
var val = jQuery.trim(m3);
if(uriReg.test(val)) val = val.replace(uriReg,'');
else val = m3;
return m1+m2+val+m4+m5;
});
return content;
}
});