default editor 수정

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4768 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ngleader 2008-11-05 08:56:58 +00:00
parent cfe72f0d74
commit a818600554
12 changed files with 226 additions and 45 deletions

View file

@ -133,8 +133,8 @@ function editorStart(editor_sequence, primary_key, content_key, editor_height, f
// editorMode를 기본으로 설정
editorMode[editor_sequence] = null;
// 에디터를 시작 시킴
try {
// 에디터를 시작 시킴
try {
iframe_obj.contentWindow.document.designMode = 'On';
} catch(e) {
}
@ -148,11 +148,11 @@ function editorStart(editor_sequence, primary_key, content_key, editor_height, f
/**
* 더블클릭이나 키눌림등의 각종 이벤트에 대해 listener 추가
* 작성시 필요한 이벤트 체크
* 이벤트의 경우 윈도우 sp1 (NT or xp sp1) 에서 iframe_obj.contentWindow.document에 대한 권한이 없기에 try 문으로 감싸서
* 이벤트의 경우 윈도우 sp1 (NT or xp sp1) 에서 iframe_obj.contentWindow.document에 대한 권한이 없기에 try 문으로 감싸서
* 에러를 무시하도록 해야 .
**/
// 위젯 감시를 위한 더블클릭 이벤트 걸기
// 위젯 감시를 위한 더블클릭 이벤트 걸기
try {
xAddEventListener(iframe_obj.contentWindow.document,'dblclick',editorSearchComponent);
} catch(e) {
@ -209,7 +209,7 @@ function editorKeyPress(evt) {
switch(pTag) {
case 'li' :
return;
break;
break;
default :
obj.pasteHTML("<br />");
break;
@ -301,11 +301,19 @@ function editorKeyPress(evt) {
xStopPropagation(evt);
break;
// underline
case 117 :
case 117 :
editorDo('Underline',null,e.target);
xPreventDefault(evt);
xStopPropagation(evt);
break;
//RemoveFormat
case 100 :
editorDo('RemoveFormat',null,e.target);
xPreventDefault(evt);
xStopPropagation(evt);
break;
// strike
/*
case 83 :
@ -363,6 +371,16 @@ function editorChangeFontSize(obj,srl) {
obj.selectedIndex = 0;
}
function editorUnDo(obj,srl) {
editorDo('undo','',srl);
obj.selectedIndex = 0;
}
function editorReDo(obj,srl) {
editorDo('redo','',srl);
obj.selectedIndex = 0;
}
function editorChangeHeader(obj,srl) {
var value = obj.options[obj.selectedIndex].value;
if(!value) return;
@ -374,6 +392,49 @@ function editorChangeHeader(obj,srl) {
/**
* HTML 편집 기능 활성/비활성
**/
function editorChangeMode(mode, editor_sequence) {
var iframe_obj = editorGetIFrame(editor_sequence);
if(!iframe_obj) return;
var textarea_obj = editorGetTextArea(editor_sequence);
xWidth(textarea_obj, xWidth(iframe_obj.parentNode));
xHeight(textarea_obj, xHeight(iframe_obj.parentNode));
var contentDocument = iframe_obj.contentWindow.document;
// html 편집 사용시
if(mode == 'html') {
var html = contentDocument.body.innerHTML;
html = html.replace(/<br>/ig,"<br />\n");
html = html.replace(/<br \/>\n\n/ig,"<br />\n");
textarea_obj.value = html;
// iframe_obj.parentNode.style.display = "none";
xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor html';
editorMode[editor_sequence] = 'html';
xGetElementById('use_rich_'+editor_sequence).className = '';
xGetElementById('use_html_'+editor_sequence).className = 'active';
// 위지윅 모드 사용시
} else {
var html = textarea_obj.value;
contentDocument.body.innerHTML = html;
// iframe_obj.parentNode.style.display = "block";
xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor rich';
editorMode[editor_sequence] = null;
xGetElementById('use_rich_'+editor_sequence).className = 'active';
xGetElementById('use_html_'+editor_sequence).className = '';
}
}
/*
function editorChangeMode(obj, editor_sequence) {
var iframe_obj = editorGetIFrame(editor_sequence);
if(!iframe_obj) return;
@ -385,7 +446,7 @@ function editorChangeMode(obj, editor_sequence) {
var contentDocument = iframe_obj.contentWindow.document;
// html 편집 사용시
if(obj.checked) {
if(obj.checked || obj == 'html') {
var html = contentDocument.body.innerHTML;
html = html.replace(/<br>/ig,"<br />\n");
html = html.replace(/<br \/>\n\n/ig,"<br />\n");
@ -409,11 +470,49 @@ function editorChangeMode(obj, editor_sequence) {
}
}
*/
// Editor Info Close
function closeEditorInfo(editor_sequence) {
xGetElementById('editorInfo_'+editor_sequence).style.display='none';
xGetElementById('editorInfo_'+editor_sequence).style.display='none';
var expire = new Date();
expire.setTime(expire.getTime()+ (7000 * 24 * 3600000));
xSetCookie('EditorInfo', '1', expire);
}
function showEditorHelp(e,editor_sequence){
var oid = 'editorHelp_'+editor_sequence;
if(xGetElementById(oid).className =='editorHelp'){
xGetElementById(oid).className = 'editorHelp open';
if(e.pageX <= xWidth('helpList_'+editor_sequence)){
xGetElementById('helpList_'+editor_sequence).style.right='auto';
xGetElementById('helpList_'+editor_sequence).style.left='0';
}else{
xGetElementById('helpList_'+editor_sequence).style.right='0';
xGetElementById('helpList_'+editor_sequence).style.left='';
}
}else{
xGetElementById(oid).className = 'editorHelp';
}
}
function showEditorExtension(e,editor_sequence){
var oid = 'editorExtension_'+editor_sequence;
if(xGetElementById(oid).className =='extension2'){
xGetElementById(oid).className = 'extension2 open';
if(e.pageX <= xWidth('editor_component_'+editor_sequence)){
xGetElementById('editor_component_'+editor_sequence).style.right='auto';
xGetElementById('editor_component_'+editor_sequence).style.left='0';
}else{
xGetElementById('editor_component_'+editor_sequence).style.right='0';
xGetElementById('editor_component_'+editor_sequence).style.left='';
}
}else{
xGetElementById(oid).className = 'extension2';
}
}

View file

@ -97,10 +97,12 @@ function editorRemoveSavedDoc() {
// editor_sequence값에 해당하는 iframe의 object를 return
function editorGetIFrame(editor_sequence) {
if(editorRelKeys != undefined && editorRelKeys[editor_sequence] != undefined && editorRelKeys[editor_sequence]['editor'] != undefined)
return editorRelKeys[editor_sequence]['editor'].getFrame();
return editorRelKeys[editor_sequence]['editor'].getFrame();
return xGetElementById( 'editor_iframe_'+ editor_sequence );
}
function editorGetTextarea(editor_sequence) {
return xGetElementById( 'editor_textarea_'+ editor_sequence );
}
/**
* iframe 세로 크기 조절 드래그 관련
**/
@ -118,15 +120,21 @@ function editorDragStart(evt) {
editorDragObj.id = id.substr('editor_drag_bar_'.length);
var iframe_obj = editorGetIFrame(editorDragObj.id);
var textarea_obj = editorGetTextarea(editorDragObj.id);
editorDragObj.source_height = xHeight(iframe_obj);
xGetElementById('xeEditorMask_' + editorDragObj.id).style.display='block';
xAddEventListener(document, 'mousemove', editorDragMove, false);
xAddEventListener(editorDragObj.obj, 'mousemove', editorDragMove, false);
xAddEventListener(document, 'mousemove', editorDragMove, true);
// xAddEventListener(editorDragObj.obj, 'mousemove', editorDragMove, false);
}
function editorDragMove(evt) {
if(!editorDragObj.isDrag) return;
if(!editorDragObj.isDrag){
if(editorDragObj.id) xGetElementById('xeEditorMask_' + editorDragObj.id).style.display='none';
return;
}
var e = new xEvent(evt);
var h = e.pageY - editorDragObj.y;
@ -135,37 +143,48 @@ function editorDragMove(evt) {
editorDragObj.y = e.pageY;
editorDragObj.obj = e.target;
var iframe_obj = editorGetIFrame(editorDragObj.id);
xHeight(iframe_obj, xHeight(iframe_obj)+h);
xHeight(iframe_obj.parentNode, xHeight(iframe_obj)+10);
var textarea_obj = editorGetTextarea(editorDragObj.id);
var height = xHeight(iframe_obj) || xHeight(textarea_obj);
height += h;
xHeight(iframe_obj, height);
xHeight(textarea_obj, height);
xHeight(iframe_obj.parentNode, height+10);
}
function editorDragStop(evt) {
if(!editorDragObj.isDrag) return;
if(editorDragObj.id) xGetElementById('xeEditorMask_'+editorDragObj.id).style.display='none';
if(!editorDragObj.isDrag){
return;
}
xRemoveEventListener(document, 'mousemove', editorDragMove, false);
xRemoveEventListener(editorDragObj.obj, 'mousemove', editorDragMove, false);
// xRemoveEventListener(editorDragObj.obj, 'mousemove', editorDragMove, false);
var iframe_obj = editorGetIFrame(editorDragObj.id);
var textarea_obj = editorGetTextarea(editorDragObj.id);
if(typeof(fixAdminLayoutFooter)=='function') fixAdminLayoutFooter(xHeight(iframe_obj)-editorDragObj.source_height);
editorDragObj.isDrag = false;
editorDragObj.y = 0;
editorDragObj.obj = null;
editorDragObj.id = '';
}
// Editor Option Button
// Editor Option Button
function eOptionOver(obj) {
obj.style.marginTop='-21px';
obj.style.zIndex='99';
obj.style.marginTop='-21px';
obj.style.zIndex='99';
}
function eOptionOut(obj) {
obj.style.marginTop='0';
obj.style.zIndex='1';
obj.style.marginTop='0';
obj.style.zIndex='1';
}
function eOptionClick(obj) {
obj.style.marginTop='-42px';
obj.style.marginTop='-42px';
obj.style.zIndex='99';
}
@ -178,7 +197,7 @@ var editorPrevSrl = null;
function editorEventCheck(evt) {
editorPrevNode = null;
// 이벤트가 발생한 object의 ID를 구함
// 이벤트가 발생한 object의 ID를 구함
var e = new xEvent(evt);
var target_id = e.target.id;
if(!target_id) return;
@ -194,7 +213,7 @@ function editorEventCheck(evt) {
switch(component_name) {
// 기본 기능에 대한 동작 (바로 실행)
// 기본 기능에 대한 동작 (바로 실행)
case 'Bold' :
case 'Italic' :
case 'Underline' :
@ -247,7 +266,7 @@ function editorSearchComponent(evt) {
editorPrevNode = null;
var obj = e.target;
// 위젯인지 일단 체크
if(obj.getAttribute("widget")) {
// editor_sequence을 찾음
@ -291,7 +310,7 @@ function editorSearchComponent(evt) {
} else if(obj.nodeName == "TD") {
editor_component = "table_maker";
editorPrevNode = obj;
// 링크거나 텍스트인 경우
} else if(obj.nodeName == "A" || obj.nodeName == "BODY" || obj.nodeName.indexOf("H")==0 || obj.nodeName == "LI" || obj.nodeName == "P") {
editor_component = "url_link";