mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
8d44a0fd92
* chore: Migrate from JSZip to Yazl * Add koa stream helper, PR feedback
37 lines
1007 B
TypeScript
37 lines
1007 B
TypeScript
import { ZipFile } from "yazl";
|
|
import type { NavigationNode } from "@shared/types";
|
|
import { FileOperationFormat } from "@shared/types";
|
|
import type { Collection, FileOperation } from "@server/models";
|
|
import type { Document } from "@server/models";
|
|
import ExportDocumentTreeTask from "./ExportDocumentTreeTask";
|
|
|
|
export default class ExportHTMLZipTask extends ExportDocumentTreeTask {
|
|
public async exportCollections(
|
|
collections: Collection[],
|
|
fileOperation: FileOperation
|
|
) {
|
|
const zip = new ZipFile();
|
|
|
|
return await this.addCollectionsToArchive(
|
|
zip,
|
|
collections,
|
|
FileOperationFormat.HTMLZip,
|
|
fileOperation.options?.includeAttachments ?? true
|
|
);
|
|
}
|
|
|
|
public async exportDocument(
|
|
document: Document,
|
|
documentStructure: NavigationNode[]
|
|
): Promise<string> {
|
|
const zip = new ZipFile();
|
|
|
|
return await this.addDocumentToArchive({
|
|
document,
|
|
documentStructure,
|
|
format: FileOperationFormat.HTMLZip,
|
|
zip,
|
|
});
|
|
}
|
|
}
|