beforeExportFile

3.3.2603 버전부터 지원합니다.

문서가 내보내지기 전에 발생합니다.

이벤트 객체를 통해 내보내기 API, 요청 헤더, 매개변수를 변경할 수 있습니다.

이벤트 등록: API 사용

var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
var editor = new SynapEditor(editorId, editorConfig, html);

editor.setEventListener('beforeExportFile', function (e) {
});

이벤트 등록: 함수 방식

var editorId = 'synapEditor';
var editorConfig = {};
var html = '';

function SynapEditorBeforeExportFile(e) {
}

new SynapEditor(editorId, editorConfig, html);

이벤트 등록: 에디터 초기화 시 등록

var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
var eventListeners = {
    beforeExportFile: function (e) {
    }
};

new SynapEditor(editorId, editorConfig, html, eventListeners);

함수에 전달된 객체의 Shape

함수에 전달되는 매개변수 e의 형태는 다음과 같습니다.

// release 3.3.2603 and above
e = {
    editor: SynapEditor,
    eventType: 'beforeExportFile',
    cancelable: false,
    returnValue: null,
    fileName: 'exportFileName',     // default: 'untitled'
    pageOrientation: 'portrait',    // 'portrait'(default) | 'landscape'
    exportFileFormat: 'hwpx'        // 'docx' | 'hwpx'(default) | 'hwp'
}

API

event.setApi(api)

이벤트 객체를 통해 내보내기 API를 설정할 수 있습니다.

{
    beforeExportFile: function (e) {
        e.setApi('newExportURL');
    }
}

event.addHeader(key, value)

이벤트 객체를 통해 요청 헤더를 설정할 수 있습니다.

{
    beforeExportFile: function (e) {
        e.addHeader('X-Hello', 'World');
    }
}

event.addParameter(key, value)

이벤트 객체를 통해 매개변수를 설정할 수 있습니다.

{
    beforeExportFile: function (e) {
        e.addParameter('hello', 'world');
    }
}