mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* feat: Add Open Knowledge Format (OKF) export Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Separate OKF frontmatter from body, use team URL for resource Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Use OKF initials avatar in export dialog Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Use GlobeIcon for OKF export format Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
import { FileOperationFormat, FileOperationType } from "@shared/types";
|
|
import { FileOperation } from "@server/models";
|
|
import type { Event as TEvent, FileOperationEvent } from "@server/types";
|
|
import ExportHTMLZipTask from "../tasks/ExportHTMLZipTask";
|
|
import ExportJSONTask from "../tasks/ExportJSONTask";
|
|
import ExportMarkdownZipTask from "../tasks/ExportMarkdownZipTask";
|
|
import ExportOKFZipTask from "../tasks/ExportOKFZipTask";
|
|
import ExportTextBundleZipTask from "../tasks/ExportTextBundleZipTask";
|
|
import BaseProcessor from "./BaseProcessor";
|
|
|
|
export default class FileOperationCreatedProcessor extends BaseProcessor {
|
|
static applicableEvents: TEvent["name"][] = ["fileOperations.create"];
|
|
|
|
async perform(event: FileOperationEvent) {
|
|
const fileOperation = await FileOperation.unscoped().findByPk(
|
|
event.modelId,
|
|
{
|
|
rejectOnEmpty: true,
|
|
}
|
|
);
|
|
|
|
// Imports no longer flow through FileOperation — both JSON and Markdown
|
|
// zip imports run through the API-import pipeline (`imports.create` →
|
|
// {Markdown,JSON}APIImportTask). This dispatcher only handles exports.
|
|
if (fileOperation.type === FileOperationType.Export) {
|
|
switch (fileOperation.format) {
|
|
case FileOperationFormat.HTMLZip:
|
|
await new ExportHTMLZipTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
case FileOperationFormat.MarkdownZip:
|
|
await new ExportMarkdownZipTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
case FileOperationFormat.OKFZip:
|
|
await new ExportOKFZipTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
case FileOperationFormat.TextBundleZip:
|
|
await new ExportTextBundleZipTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
case FileOperationFormat.JSON:
|
|
await new ExportJSONTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|