mirror of
https://github.com/outline/outline.git
synced 2026-08-03 13:27:25 +03:00
* feat: Add TextPack (.textpack) import support Adds a single-document importer for TextPack, the zipped variant of TextBundle used by Bear, Ulysses, iA Writer and others. Bare .textbundle directories are not supported, as a directory cannot be delivered through a browser file input. The bundle's text entry may use any extension, per the spec, with info.json's type deciding whether it can be read as markdown. Assets are inlined as data URIs for the existing attachment pipeline to pick up, bounded by the attachment size limit and a memory ceiling, and only for media types markdown-it accepts as a link destination. Also fixes an existing bug where a file embedded in an HTML or email import as a data URI was stored in the document as base64 rather than being uploaded as an attachment. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Refactor to individual converters * refactor --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 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 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.TextBundleZip:
|
|
await new ExportTextBundleZipTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
case FileOperationFormat.JSON:
|
|
await new ExportJSONTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|