19 lines
746 B
JavaScript
19 lines
746 B
JavaScript
|
// 等待 docx.min.js 加载完成
|
||
|
const waitForDocx = new Promise((resolve) => {
|
||
|
const checkDocx = () => {
|
||
|
if (window.docx && window.docx.Document) {
|
||
|
resolve();
|
||
|
} else {
|
||
|
setTimeout(checkDocx, 100);
|
||
|
}
|
||
|
};
|
||
|
checkDocx();
|
||
|
});
|
||
|
|
||
|
// 导出 docx 库的所有必要组件
|
||
|
export const Document = waitForDocx.then(() => window.docx.Document);
|
||
|
export const Paragraph = waitForDocx.then(() => window.docx.Paragraph);
|
||
|
export const ImageRun = waitForDocx.then(() => window.docx.ImageRun);
|
||
|
export const HeadingLevel = waitForDocx.then(() => window.docx.HeadingLevel);
|
||
|
export const AlignmentType = waitForDocx.then(() => window.docx.AlignmentType);
|
||
|
export const Packer = waitForDocx.then(() => window.docx.Packer);
|