mirror of
https://github.com/open-webui/open-webui.git
synced 2026-01-02 06:35:20 +00:00
feat: Dynamically load mammoth to speed up page loading (#20202)
This commit is contained in:
parent
464846d4a3
commit
935808f5ea
1 changed files with 4 additions and 2 deletions
|
|
@ -15,7 +15,6 @@ dayjs.extend(localizedFormat);
|
||||||
|
|
||||||
import { TTS_RESPONSE_SPLIT } from '$lib/types';
|
import { TTS_RESPONSE_SPLIT } from '$lib/types';
|
||||||
|
|
||||||
import mammoth from 'mammoth';
|
|
||||||
import pdfWorkerUrl from 'pdfjs-dist/build/pdf.worker.mjs?url';
|
import pdfWorkerUrl from 'pdfjs-dist/build/pdf.worker.mjs?url';
|
||||||
|
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
|
|
@ -1521,7 +1520,10 @@ export const extractContentFromFile = async (file: File) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractDocxText(file: File) {
|
async function extractDocxText(file: File) {
|
||||||
const arrayBuffer = await file.arrayBuffer();
|
const [arrayBuffer, { default: mammoth }] = await Promise.all([
|
||||||
|
file.arrayBuffer(),
|
||||||
|
import('mammoth')
|
||||||
|
]);
|
||||||
const result = await mammoth.extractRawText({ arrayBuffer });
|
const result = await mammoth.extractRawText({ arrayBuffer });
|
||||||
return result.value; // plain text
|
return result.value; // plain text
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue