#197 페이지 수정시 기존의 방법으로는 에디터 부분에 focus를 주어야 에디터 활성화 되어 페이지 수정이 가능했으나 위젯을 바로 추가한다든지 하는 행동에 대해서 바로 에디터 활성화를 시키도록 하여 문제 해결.

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2691 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-10-08 11:10:45 +00:00
parent 89b9a83e60
commit 88399a506a

View file

@ -100,6 +100,8 @@ function editorGetSelectedNode(editor_sequence) {
/**
* editor 시작 (editor_sequence로 iframe객체를 얻어서 쓰기 모드로 전환)
**/
var editor_is_started = new Array();
var editor_start_func = new Array();
function editorStart(editor_sequence, primary_key, content_key, resizable, editor_height) {
// resize 가/불가에 대한 체크
if(typeof(resizable)=="undefined"||!resizable) resizable = false;
@ -174,17 +176,20 @@ function editorStart(editor_sequence, primary_key, content_key, resizable, edito
// editor_mode를 기본으로 설정
editor_mode[editor_sequence] = null;
editor_is_started[editor_sequence] = false;
xAddEventListener(document,'mouseup',editorEventCheck);
// iframe에 focus가 될때 에디터 모드로 전환하도록 이벤트 지정
if(xIE4Up) xAddEventListener(iframe_obj, "focus", function() { editorSetDesignMode(iframe_obj, contentDocument, content, fo_obj, editor_sequence, editor_height); } );
else xAddEventListener(iframe_obj.contentWindow, "focus", function() { editorSetDesignMode(iframe_obj, contentDocument, content, fo_obj, editor_sequence, editor_height); } );
editor_start_func[editor_sequence] = function() { editorSetDesignMode(iframe_obj, contentDocument, content, fo_obj, editor_sequence); }
if(xIE4Up) xAddEventListener(iframe_obj, "focus", editor_start_func[editor_sequence] );
else xAddEventListener(iframe_obj.contentWindow, "focus", editor_start_func[editor_sequence] );
}
/**
* 에디터를 위지윅 모드로 만들기 위해 내용 작성 designMode 활성화
**/
var editor_is_started = new Array();
function editorSetDesignMode(iframe_obj, contentDocument, content, fo_obj, editor_sequence, editor_height) {
function editorSetDesignMode(iframe_obj, contentDocument, content, fo_obj, editor_sequence ) {
if(editor_is_started[editor_sequence]) return;
contentDocument.designMode = 'on';
@ -211,7 +216,6 @@ function editorSetDesignMode(iframe_obj, contentDocument, content, fo_obj, edito
}
xAddEventListener(document,'dblclick',editorSearchComponent);
xAddEventListener(document,'mouseup',editorEventCheck);
xAddEventListener(document,'mousedown',editorHideObject);
/**
@ -328,7 +332,19 @@ function editorFocus(editor_sequence) {
// 에디터 내의 선택된 부분의 html코드를 변경
function editorReplaceHTML(iframe_obj, html) {
// 에디터가 활성화 되어 있는지 확인 후 비활성화시 활성화
var editor_sequence = iframe_obj.contentWindow.document.body.getAttribute("editor_sequence");
if(!editor_is_started[editor_sequence]) {
try {
editor_start_func[editor_sequence];
} catch(e) {
return;
}
}
// iframe 에디터에 포커스를 둠
iframe_obj.contentWindow.focus();
if(xIE4Up) {
var range = iframe_obj.contentWindow.document.selection.createRange();
if(range.pasteHTML) {
@ -336,7 +352,9 @@ function editorReplaceHTML(iframe_obj, html) {
} else if(editorPrevNode) {
editorPrevNode.outerHTML = html;
}
} else {
if(iframe_obj.contentWindow.getSelection().focusNode.tagName == "HTML") {
var range = iframe_obj.contentDocument.createRange();
range.setStart(iframe_obj.contentDocument.body,0);
@ -347,6 +365,7 @@ function editorReplaceHTML(iframe_obj, html) {
range.deleteContents();
range.insertNode(range.createContextualFragment(html));
}
}
}
@ -721,6 +740,15 @@ function editorHideObject(evt) {
* HTML 편집 기능 활성/비활성
**/
function editorChangeMode(obj, editor_sequence) {
// 에디터가 활성화 되어 있는지 확인 후 비활성화시 활성화
if(!editor_is_started[editor_sequence]) {
try {
editor_start_func[editor_sequence];
} catch(e) {
return;
}
}
var iframe_obj = editorGetIFrame(editor_sequence);
if(!iframe_obj) return;