/**
 * docx-preview 高保真 Word 渲染（预览区）
 */
import { renderAsync } from 'docx-preview';

var DEFAULT_RENDER_OPTIONS = {
	className: 'ct-docx-preview',
	inWrapper: true,
	ignoreWidth: false,
	ignoreHeight: false,
	ignoreFonts: false,
	breakPages: true,
	ignoreLastRenderedPageBreak: true,
	trimXmlDeclaration: true,
	useBase64URL: true,
};

export async function renderDocxPreview(container, arrayBuffer, options) {
	if (!container || !arrayBuffer) return;
	container.innerHTML = '';
	await renderAsync(
		arrayBuffer,
		container,
		null,
		Object.assign({}, DEFAULT_RENDER_OPTIONS, options || {})
	);
}
