afterOpenDocument
2.3.0 버전부터 지원합니다.
문서가 열린 후(임포트 후)에 발생합니다.
이벤트 등록: API 사용
var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
var editor = new SynapEditor(editorId, editorConfig, html);
editor.setEventListener('afterOpenDocument', function (e) {
});
이벤트 등록: 함수 방식
var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
function SynapEditorAfterOpenDocument(e) {
}
new SynapEditor(editorId, editorConfig, html);
이벤트 등록: 에디터 초기화 시 등록
var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
var eventListeners = {
afterOpenDocument: function (e) {
}
};
new SynapEditor(editorId, editorConfig, html, eventListeners);
함수에 전달된 객체의 Shape
함수에 전달되는 매개변수 e의 형태는 다음과 같습니다.
e = {
editor: SynapEditor,
eventType: 'afterOpenDocument',
cancelable: true,
returnValue: null,
fileType: 'WORD', // File type ('HTML', 'WORD', 'CELL', ...)
path: '/upload/path/filename.docx', // Import path
...... // Data received from the server (importPath, serializedData, .....)
}
// release 2.15.0 and above
e = {
editor: SynapEditor,
eventType: 'afterOpenDocument',
cancelable: true,
returnValue: null,
fileType: 'WORD',
path: '/upload/path/filename.docx',
error: undefined, // [2.15.0] Error information when import fails
...... // Data received from the server (importPath, serializedData, .....)
}
임포트 실패
2.15.0 버전부터 지원합니다.
릴리즈 2.15.0부터 afterOpenDocument 이벤트는 임포트가 실패할 때도 발생합니다.
임포트가 실패하면 Error 객체가 afterOpenDocument 이벤트 객체의 error 속성에 담깁니다.
임포트에 실패했을 때 오류 메시지를 확인하는 예시:
editor.setEventListener('afterOpenDocument', function (e) {
if (e.error) {
console.log(e.error);
}
});