mirror of
https://github.com/outline/outline.git
synced 2026-11-28 16:19:46 +03:00
Slab exports wrap the entire workspace in a single top-level directory named "slab". Without handling this, the import produces one "slab" collection containing everything, instead of mapping each workspace area to its own collection. Add a `resolveCollectionRootNodes` seam on the Markdown bootstrap phase (default: pass entries through unchanged) and override it in SlabAPIImportTask to descend into a lone, case-insensitive "slab" root directory so its child directories become collections. Paths are left intact, so the attachment manifest, completion re-walk, and internal-link resolution stay consistent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AC5Ho2SHBjNpxEAMr5uL6o
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
import type { IntegrationService } from "@shared/types";
|
|
import type { ImportTask } from "@server/models";
|
|
import type { ZipTreeNode } from "@server/utils/ZipHelper";
|
|
import MarkdownAPIImportTask from "./MarkdownAPIImportTask";
|
|
|
|
type Service = IntegrationService.Markdown | IntegrationService.Slab;
|
|
|
|
/**
|
|
* Imports a Slab workspace export.
|
|
*
|
|
* Slab exports the same zip-of-Markdown structure as Outline's own Markdown
|
|
* export, so all conversion, attachment, and persistence logic is inherited
|
|
* from {@link MarkdownAPIImportTask}. This subclass exists as a dedicated
|
|
* seam for Slab-specific behavior (e.g. quirks in how Slab references remote
|
|
* assets) and so Slab imports are scheduled, traced, and retried under their
|
|
* own task name rather than the generic Markdown one.
|
|
*/
|
|
export default class SlabAPIImportTask extends MarkdownAPIImportTask {
|
|
protected async scheduleNextTask(
|
|
importTask: ImportTask<Service>
|
|
): Promise<void> {
|
|
await new SlabAPIImportTask().schedule({ importTaskId: importTask.id });
|
|
}
|
|
|
|
/**
|
|
* Slab exports wrap the entire workspace in a single root directory named
|
|
* "slab". When present, descend into it so the directories one level down
|
|
* are imported as collections rather than a single "slab" collection.
|
|
*
|
|
* @param nodes The archive's top-level tree nodes.
|
|
* @returns The nodes to import as collections.
|
|
*/
|
|
protected resolveCollectionRootNodes(nodes: ZipTreeNode[]): ZipTreeNode[] {
|
|
if (
|
|
nodes.length === 1 &&
|
|
nodes[0].children.length > 0 &&
|
|
nodes[0].title.toLowerCase() === "slab"
|
|
) {
|
|
return nodes[0].children;
|
|
}
|
|
return nodes;
|
|
}
|
|
}
|